Gets or Sets the path.

@param  string $value
@param  boolean $overwrite
@return string|Tarsana\Filesystem\AbstractFile

@throws Tarsana\Filesystem\Exceptions\FilesystemException if could not rename the file.
504571
public function path($value = false, $overwrite = false)
    {
        if ($value === false) {
            return $this->path;
        }

        $oldPath = $this->path;

        if (!$overwrite && $this->adapter->fileExists($value)) {
            throw new FilesystemException("Cannot rename the file '{$this->path}' to '{$value}' because a file already exists");
        }

        (new static($value, $this->adapter))->remove();

        if (! $this->adapter->rename($this->path, $value)) {
            throw new FilesystemException("Cannot rename the file '{$this->path}' to '{$value}'");
        }

        $this->path = $value;
        $this->fs = null;
        $this->pathChanged($oldPath);

        return $this;
    }
1024403
public static function copyDirectory($oldDir, $aimDir, $overWrite = false) {
		$aimDir = str_replace('', '/', $aimDir);
		$aimDir = substr($aimDir, -1) == '/' ? $aimDir : $aimDir . '/';
		$oldDir = str_replace('', '/', $oldDir);
		$oldDir = substr($oldDir, -1) == '/' ? $oldDir : $oldDir . '/';
		if (!is_dir($oldDir)) {
			return false;
		}
		if (!is_dir($aimDir)) {
			self::createDir($aimDir);
		}
		$dirHandle = opendir($oldDir);
		while (false !== ($file = readdir($dirHandle))) {
			if ($file == '.' || $file == '..') {
				continue;
			}
			if (!is_dir($oldDir . $file)) {
				self::copyFile($oldDir . $file, $aimDir . $file, $overWrite);
			} else {
				self:: copyDir($oldDir . $file, $aimDir . $file, $overWrite);
			}
		}
		return closedir($dirHandle);
	}
1352383
public function encodeFile( $fileName, $overwrite = FALSE )
	{
		if( !file_exists( $fileName ) )
			return FALSE;
		if( $this->isEncoded( $fileName ) )
			return TRUE;
		$php		= FS_File_Reader::load( $fileName );
		$code		= $this->encode( $php );
		$dirname	= dirname( $fileName );
		$basename	= basename( $fileName );
		$target		= $dirname."/".$this->filePrefix.$basename.$this->fileSuffix;
		if( $fileName == $target && !$overwrite )
			throw new RuntimeException( 'File cannot be overwritten, use Parameter "overwrite".' );
//		copy( $fileName, "#".$fileName );
		return (bool) FS_File_Writer::save( $target, $code );
	}
445966
public function findDestination($file, $overwrite = false) {
        if ($file instanceof File) {
            $name = $file->name();
            $ext = '.' . $file->ext();

        } else {
            $name = $file;
            $ext = '';

            if ($pos = mb_strrpos($name, '.')) {
                $ext = mb_substr($name, $pos, (mb_strlen($name) - $pos));
                $name = mb_substr($name, 0, $pos);
            }
        }

        function endsWith($haystack, $needle) {
            // search forward starting from end minus needle length characters
            return $needle === "" || strpos($haystack, $needle, strlen($haystack) - strlen($needle)) !== FALSE;
        }

        $retina = false;
        if(endsWith($name, "@2x")) { 
            $name = explode("@2x", $name);
            $name = $name[0].$name[1];
            $retina = true;
        }

        $target = $this->_directory . $name . $ext;

        if (!$overwrite) {
            $no = 1;

            while (file_exists($target)) {
                if ($retina) {
                    $target = sprintf('%s%s-%s@2x%s', $this->_directory, $name, $no, $ext);
                } else {
                    $target = sprintf('%s%s-%s%s', $this->_directory, $name, $no, $ext);
                }
                $no++;
            }
        }

        return $target;
    }
112365
public function moveDirectory( $from, $to, $overwrite = false ): bool
	{
		if( $overwrite && $this->isDirectory( $to ) && ! $this->deleteDirectory( $to ) )
		{
			return false;
		}
		return @ rename( $from, $to ) === true;
	}
833554
public function set($property, $value = null, $overwrite = false)
    {

        $previous = isset($this->$property) ? $this->$property : null;

        $this->$property = $value;

        return $previous;
    }
513564
protected function writeContent($content = '', $overwrite = true)
    {
        $this->filesystem->write($this->key, $content, $overwrite);

        return $content;
    }
401504
public function assign(string $key, $value, bool $overwrite = false)
  {
    $file = $this->file;

    if (file_exists($file)) {
      $data = unserialize($this->decrypt(file_get_contents($file)));

      if (is_array($data)) {
        if (isset($data[$key])) {
          if ($overwrite == true) {
            $data[$key] = $value;
            $data = $this->encrypt(serialize($data));
            return file_put_contents($file, $data);
          }
          return false;
        } else {
          $data[$key] = $value;
          $data = $this->encrypt(serialize($data));
          return file_put_contents($file, $data);
        }
      }
    }

    $data = $this->encrypt(serialize([$key => $value]));

    file_put_contents($file, $data);

    return false;
  }
183601
public function assign($vars, $overwrite=true)
	{
		if(!$overwrite)
		{
			$vars = array_merge($this->_vars, $vars);
		}
		$this->_vars = $vars;
		return $this;
	}
1271690
public function extend($basedir = null, $overwrite = false)
    {
        if (null === $basedir) {
            $basedir = $this->basedir;
        }

        $basedir = File::realpath($basedir);

        if (false === $this->loadFromCache($basedir)) {
            $this->loadFromBaseDir($basedir, $overwrite);
            $this->saveToCache($basedir);
        }

        if (
            !empty($this->environment)
            && false === strpos($this->environment, $basedir)
            && is_dir($basedir.DIRECTORY_SEPARATOR.$this->environment)
        ) {
            $this->extend($basedir.DIRECTORY_SEPARATOR.$this->environment, $overwrite);
        }

        return $this;
    }
123977
public function fileMove($src, $dst, $overwrite = false)
    {
        $src = $this->alias->resolve($src);
        $dst = $this->alias->resolve($dst);

        if (rtrim($dst, '\\/') !== $dst) {
            $dst .= basename($src);
        }

        if (!$overwrite && is_file($dst)) {
            throw new RuntimeException(['move `:src` to `:dst` failed: file exists already', 'src' => $src, 'dst' => $dst]);
        }

        if (!is_dir($dir = dirname($dst))) {
            $this->_dirCreate($dir);
        }

        if (!rename($src, $dst)) {
            throw new RuntimeException(['move `:src` to `:dst` failed: :last_error_message', 'src' => $src, 'dst' => $dst]);
        }
    }
829539
public function syncWithTemplate($filePath, $overwrite = FALSE) {
    $sourcePath = $this->getBltRoot() . '/template/' . $filePath;
    $targetPath = $this->getRepoRoot() . '/' . $filePath;

    if ($this->getFileSystem()->exists($sourcePath)) {
      try {
        $this->getFileSystem()->copy($sourcePath, $targetPath, $overwrite);
      }
      catch (IOException $e) {
        throw $e;
      }
    }

  }
457159
public function dirMove($src, $dst, $overwrite = false)
    {
        $src = $this->alias->resolve($src);
        $dst = $this->alias->resolve($dst);

        if (!$overwrite && is_dir($dst)) {
            throw new RuntimeException(['move `:src` to `:dst` failed: destination directory is exists already', 'src' => $src, 'dst' => $dst]);
        }

        if (!is_dir($dir = dirname($dst))) {
            $this->_dirCreate($dir);
        }

        if (!rename($src, $dst)) {
            throw new RuntimeException(['move `:src` directory to `:dst` directory failed: :last_error_message', 'src' => $src, 'dst' => $dst]);
        }
    }
1275255
public function fileCopy($src, $dst, $overwrite = false)
    {
        if (rtrim($dst, '\\/') !== $dst) {
            $dst .= basename($src);
        }

        $src = $this->alias->resolve($src);
        $dst = $this->alias->resolve($dst);

        if ($overwrite || !is_file($dst)) {
            $this->_dirCreate(dirname($dst));

            if (!copy($src, $dst)) {
                throw new RuntimeException(['move `:src` to `:dst` failed: :last_error_message', 'src' => $src, 'dst' => $dst]);
            }
        }
    }
96762
public function options($options, bool $overwrite = false)
    {
        if ($overwrite) {
            $this->options = $options;
        } else {
            $this->options = array_replace_recursive($this->options, $options);
        }

        return $this;
    }
698276
public function set( $path, $value, $write = false )
	{
		$type	= gettype( $value );
		if( !in_array( $type, array( "double", "integer", "boolean", "string" ) ) )
			throw new InvalidArgumentException( "Value must be of type double, integer, boolean or string. ".ucfirst( $type )." given", E_USER_WARNING );
		$result	=	$this->setRecursive( $path, $value, $this->storage );
		if( $write && $result )
			return (bool) $this->write();
		return $result;
	}
914074
public function save($fileName, AdapterInterface $adapter, $overwrite = false)
	{
		$fs = new Filesystem($adapter);

		if ($overwrite == true)
		{
			$fs->put($fileName, $this->get());
		}
		else
		{
			$fs->write($fileName, $this->get());
		}

		return $this;
	}