Copy a file to dir $dir

@param \FileDB\Contracts\Model\File $file
@param \FileDB\Contracts\Model\Directory $directory
@return \FileDB\Contracts\Model\File The newly created one
502676
public function copy(FileInterface $file, DirInterface $directory)
    {
        $newFile = $this->newFile();
        $newFile->setName($file->getName());
        $newFile->setDir($directory);
        $this->fs[$newFile->getPath()] = $newFile;
        return $newFile;
    }
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;
    }
44714
public static function addDirectory($directory = '.')
    {
        $directory = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $directory);
        $directory = rtrim($directory, '/\\');
        $directory = empty($directory) ? '.' : $directory;
        array_push(self::$configDirectory, $directory);
        return true;
    }
803157
def copy_to(_, directory)
      # Delete the directory to make sure no pervious version remains
      FileUtils.rm_rf(directory) if directory.exist?

      # Create parent directory
      FileUtils.mkdir_p(directory.parent)

      # Create symlink
      FileUtils.ln_s(@dir.expand_path, directory)

      nil
    end
107296
private function AddFileToResult($directory, $file) {
        if (array_key_exists($directory, $this->FileList)) {
            array_push($this->FileList[$directory], $file);
            return;
        }
        //array_push($this->FileList, $directory);
        $this->FileList[$directory] = [$file];
    }
113585
public function files($directory)
    {
        return collect([])
            ->merge($this->filesystem->files($directory))
            ->map(function ($file) {
                return new File($file, $this);
            });
    }
770128
public function mkdir($dir)
    {
        if (!is_dir($dir)) {
            if (false === @mkdir($dir, $this->mode, true)) {
                $error = error_get_last();
                if (!is_dir($dir)) {
                    if ($error) {
                        throw new IOException(
                            sprintf('Failed to create "%s": %s.', $dir, $error['message']),
                            0,
                            null,
                            $dir
                        );
                    }
                    throw new IOException(sprintf('Failed to create "%s"', $dir), 0, null, $dir);
                }
            }
        }
    }
1182299
public function rmdir($directory) {
        if (false === @ftp_rmdir($this->getConnection(), $directory)) {
            throw $this->newFTPException(sprintf("rmdir %s failed", $directory));
        }
        return $this;
    }
646580
private function rmdir($dir)
    {
        // remove all files
        $files = scandir($dir);
        foreach ($files as $file) {
            if ($file == '.' || $file == '..') {
                continue;
            }

            $path = $dir . '/' . $file;
            if (is_dir($path)) {
                $this->rmdir($path);
            } elseif (is_file($path)) {
                unlink($path);
            }
        }

        rmdir($dir);
    }
1175420
protected function createDirectory($directory)
    {
        $isCreated = file_exists($directory) || is_dir($directory) || mkdir($directory, 0777, true);
        
        if (!$isCreated)
            throw new RuntimeException('Cannot create directory ":dir" for generated classed', ['dir' => $directory]);
        
        return $this;
    }
172046
function copyFiles(dir) {
    var files = fs.readdirSync(srcDir + dir);
    files.forEach(function(file) {
      var currentDir = dir + file;
      if (!regexExcludeFiles.test(currentDir)) {
        var stats = fs.statSync(srcDir + currentDir);
        if (stats.isDirectory()) {
          if (!fs.existsSync(publishDir + currentDir)) {
            fs.mkdirSync(publishDir + currentDir);
          }
          copyFiles(currentDir + "/");
        } else if (stats.isFile()) {
          var contents = fs.readFileSync(srcDir + currentDir);
          fs.writeFileSync(publishDir + currentDir, contents);
        }
      }
    });
  }
752196
public static void copyDir(File from, File to) throws FileNotFoundException, IOException {
        File[] files = from.listFiles();

        if (files != null) {
            for (File ff : files) {
                File tf = new File(to, ff.getName());
                if (ff.isDirectory()) {
                    if (tf.mkdir()) {
                        copyDir(ff, tf);
                    }
                } else if (ff.isFile()) {
                    copyFile(tf, ff);
                }
            }
        }
    }
988259
private function createDirectory($dir)
    {
        if (file_exists($dir)) {
            return $this;
        }
        if (false === @mkdir($dir, 0777, true)) {
            throw new \RuntimeException(sprintf('Unable to create directory "%s"', $dir));
        }
        return $this;
    }
616977
public static function rmdir( $dir ) {
		$files = new RecursiveIteratorIterator(
			new RecursiveDirectoryIterator( $dir, RecursiveDirectoryIterator::SKIP_DOTS ),
			RecursiveIteratorIterator::CHILD_FIRST
		);

		foreach ( $files as $fileinfo ) {
			$todo = $fileinfo->isDir() ? 'rmdir' : 'unlink';
			$todo( $fileinfo->getRealPath() );
		}
		rmdir( $dir );
	}
843758
public function moveToDirectory($directory)
    {
        $targetPath = rtrim($directory, '/') . '/' . $this->getClientFilename();

        return $this->moveTo($targetPath);
    }
569022
public static function create($directory = '')
    {
        if (empty($directory) || !file_exists($directory)) {
            $directory = sys_get_temp_dir();
        }

        return new Wrapper($directory);
    }
721553
public function setDirectory(Directory $directory)
    {
        $this->directory = $directory;
        $this->iterator = new \ArrayIterator($directory->children());
    }