move file into new folder,
orphaned cache entries are deleted, new cache entries are not generated

@param FilesystemFolder $destination
@return \vxPHP\File\FilesystemFile
@throws FilesystemFileException
493639
public function move(FilesystemFolder $destination) {

		// already in destination folder, nothing to do

		if($destination !== $this->folder) {

			$oldpath	= $this->folder->getPath() . $this->filename;
			$newpath	= $destination->getPath() . $this->filename;
	
			if(@rename($oldpath, $newpath)) {

				$this->clearCacheEntries();
				
				// set new folder reference

				$this->folder = $destination;
	
				// re-read fileinfo

				$this->fileInfo	= new \SplFileInfo($newpath);

				self::$instances[$newpath] = $this;
				unset(self::$instances[$oldpath]);

				// @todo: check necessity of chmod
	
				@chmod($newpath, 0666 & ~umask());
				
			}
	
			else {
				throw new FilesystemFileException("Moving from '$oldpath' to '$newpath' failed.", FilesystemFileException::FILE_RENAME_FAILED);
			}

		}

		return $this;
	}
59870
public static function getFilesystemFilesInFolder(FilesystemFolder $folder) {

		$files = [];

		$glob = glob($folder->getPath() . '*', GLOB_NOSORT);

		if($glob !== FALSE) {

			foreach($glob as $f) {
				if(!is_dir($f)) {

					if(!isset(self::$instances[$f])) {
						self::$instances[$f] = new self(basename($f), $folder);
					}

					$files[] = self::$instances[$f];
				}
			}
		}

		return $files;
	}
757062
public function upload($destination, array $files)
    {
        foreach ($files as $file) {
            if (!($file instanceof FileEntity)) {
                // This should never occur, but it's always better not to rely on framework users
                throw new LogicException(sprintf(
                    'Each file entity must be an instance of \Krystal\Http\FileTransfer\FileInfoInterface, but received "%s"', gettype($file)
                ));
            }

            // Gotta ensure again, UPLOAD_ERR_OK means there are no errors
            if ($file->getError() == \UPLOAD_ERR_OK) {
                // Start trying to move a file
                if (!$this->move($destination, $file->getTmpName(), $file->getUniqueName())) {
                    return false;
                }
            } else {
                // Invalid file, so that cannot be uploaded. That actually should be reported before inside validator
                return false;
            }
        }

        return true;
    }
922065
public function write(File $file)
    {
        $success = file_put_contents(
            $this->getRouteCachePath($file->getRoute()),
            $file->toString()
        );
        if ($success === false) {
            throw new CacheFileSystemException(
                "Unable to save Cache file to disk in file " . $this->getRouteCachePath($file->getRoute())
            );
        }
    }
665539
public static function copy(string $source, string $destination)
  {
    if (is_dir($source)) {
      @mkdir($destination);

      $directory = dir($source);

      while (false !== ($readdirectory = $directory->read())) {
        if ($readdirectory == '.' || $readdirectory == '..') {
          continue;
        }

        $PathDir = $source . '/' . $readdirectory;

        if (is_dir($PathDir)) {
          Filesystem::copy($PathDir, $destination . '/' . $readdirectory);
          continue;
        }
        copy($PathDir, $destination . '/' . $readdirectory);
      }

      $directory->close();
    } else {
      copy($source, $destination);
    }
  }
161875
public function backup($destination)
    {
        $args = [
            (string)$destination
        ];
        return null === $this->rpc->query("backupWallet", $args);
    }
18735
protected function makeDestination(string $destination): void
    {
        if (! $this->files->isDirectory($destination)) {
            $this->files->makeDirectory($destination, 0777, true);
        }
    }
761230
public function moveFiles(Filesystem $source, Filesystem $destination): void
    {
        foreach ($source->listContents() as $path) {
            if ($path['type'] === 'file') {
                $destination->put($path['path'], $source->read($path['path']));
                $source->delete($path['path']);

                if ($this->timeout_service->isTimeNearlyUp()) {
                    throw new InternalServerErrorException(I18N::translate('The server’s time limit has been reached.'));
                }
            }
        }
    }
536586
public function copy(string $source, string $destination) : bool
    {
        $status = @copy($source, $destination);

        if (false === $status) {
            throw new FileException('Cannot copy source to destination.');
        }

        return $status;
    }
922678
public function setFilesystem(FilesystemInterface $filesystem)
    {
        $this->wrapper = new FilesystemWrapper($filesystem);
        return parent::setFilesystem($this->wrapper);
    }
1088964
public function copy($destination) {
    
    if (!$this->exists()) {
      throw new Exception('Source from copy does not exist: '.$this);
    }
    
    if ($destination instanceof Dir) {
      $destination = $destination->getFile($this->getName());
    } elseif (!($destination instanceof File)) {
      throw new InvalidArgumentException('Invalid Argument. $destination must be file or dir');
    }

    if (!$destination->getDirectory()->exists()) {
      throw new Exception('The directory from the destination file does not exist: '.$destination);
    }

    $ret = @copy((string) $this, (string) $destination);

    if (!$ret) {
      throw new Exception('PHP Error while copying '.$this.' onto '.$destination);
    }
    
    return $this;
  }
270478
public function extractTo($destination, $entries = array())
    {
        $result = false;
        if (!empty($entries)) {
            $result = $this->phar->extractTo($destination, $entries);
        } else {
            $result = $this->phar->extractTo($destination);
        }
        if ($result === false) {
            throw new ArchiveException('Error extracting archive.');
        }

        return $this;
    }
126516
public function createConsumer(Destination $destination): Consumer
    {
        InvalidDestinationException::assertDestinationInstanceOf($destination, GpsQueue::class);

        return new GpsConsumer($this, $destination);
    }
944091
private function move($destination, $tmp, $filename)
    {
        if (!is_dir($destination)) {
            // We can either create it automatically
            if ($this->destinationAutoCreate === true) {
                // Then make a directory (recursively if needed)
                @mkdir($destination, 0777, true);
                
            } else {
                // Destination doesn't exist, and we shouldn't be creating it
                throw new RuntimeException(sprintf(
                    'Destination folder does not exist', $destination
                ));
            }
        }

        $target = sprintf('%s/%s', $destination, $filename);

        // If Remote file exists and we don't want to override it, so let's stop here
        if (is_file($target)) {
            if (!$this->override) {
                return true;
            }
        }

        return move_uploaded_file($tmp, $target);
    }
77725
private function copyFile(
        FilesystemInterface $source,
        FilesystemInterface $destination,
        $path
    ) {
        $destination->put(
            $path,
            $source->read($path)
        );
    }
402592
protected function write($destination, $content)
    {
        $directory = dirname($destination);

        if ( ! $this->files->exists($directory)) {
            $this->files->makeDirectory($directory, 0755, true);
        }

        return (bool) $this->files->put($destination, $content);
    }
298806
public function destination($directory)
    {
        $filesystem = new Filesystem();

        foreach ($this->current_state as $filename => $file_content) {
            $filesystem->dumpFile($directory . '/' . $filename, $file_content);
        }

        unset($this->current_state);

        return $this;
    }