Extract a ZIP or TAR archive

@param  string $src Path to the archive file
@param  string $dst Path to the destination
@return boolean
335365
public static function extract($src, $dst)
    {
        $result = false;

        $archive = \ezcArchive::open($src);
        $archive->extract($dst);
        $result = true;

        return $result;
    }
725986
protected function extractArchive(PhingFile $zipfile)
    {
        $this->log(
            "Extracting zip: " . $zipfile->__toString() . ' to ' . $this->todir->__toString(),
            Project::MSG_INFO
        );

        $zip = new ZipArchive();

        $result = $zip->open($zipfile->getAbsolutePath());
        if (!$result) {
            $this->log("Unable to open zipfile " . $zipfile->__toString(), Project::MSG_ERR);

            return false;
        }

        $result = $zip->extractTo($this->todir->getAbsolutePath());
        if (!$result) {
            $this->log("Unable to extract zipfile " . $zipfile->__toString(), Project::MSG_ERR);

            return false;
        }

        return true;
    }
799602
private function recursiveProcess($src, $dst, $pattern = null, $callback = 'copy')
    {
        $success = true;
        $iterator = new \DirectoryIterator($src);

        foreach ($iterator as $item) {
            $pathName = $item->getPathname();
            if (!is_readable($pathName)) {
                $this->logger->error('File is not readable :'.$pathName);
                continue;
            }

            $fileName = $item->getFileName();

            if ($item->isDir()) {
                if ('.' != $fileName && '..' != $fileName && '.libs' != $fileName) {
                    if (!is_dir($dst.\DIRECTORY_SEPARATOR.$fileName)) {
                        mkdir($dst.\DIRECTORY_SEPARATOR.$fileName, 0755, true);
                    }
                    $this->recursiveProcess($pathName, $dst.\DIRECTORY_SEPARATOR.$fileName, $pattern, $callback);
                }
            } elseif (!$pattern || ($pattern && 1 === preg_match($pattern, $fileName))) {
                $path = $dst.\DIRECTORY_SEPARATOR.$fileName;
                $success = $success && \call_user_func($callback, $pathName, $path);
            }
        }

        return $success;
    }
365607
public function thumb(string $src, string $dst, integer $width, integer $height)
    {
        $anchor='center';
        return $this
        ->image($src)
        ->thumbnail($width, $height, $anchor)
        ->toFile($dst);
    }
1153899
public function moveTo($dst, $allowedExtensions = 'jpg,jpeg,png,gif,doc,xls,pdf,zip', $overwrite = false)
    {
        if ($allowedExtensions !== '*') {
            $extension = pathinfo($dst, PATHINFO_EXTENSION);
            if (!$extension || preg_match("#\b$extension\b#", $allowedExtensions) !== 1) {
                throw new FileException(['`:extension` file type is not allowed upload', 'extension' => $extension]);
            }
        }

        if ($this->_file['error'] !== UPLOAD_ERR_OK) {
            throw new FileException(['error code of upload file is not UPLOAD_ERR_OK: :error', 'error' => $this->_file['error']]);
        }

        if ($this->filesystem->fileExists($dst)) {
            if ($overwrite) {
                $this->filesystem->fileDelete($dst);
            } else {
                throw new FileException(['`:file` file already exists', 'file' => $dst]);
            }
        }

        $this->filesystem->dirCreate(dirname($dst));

        if (!move_uploaded_file($this->_file['tmp_name'], $this->alias->resolve($dst))) {
            throw new FileException(['move_uploaded_file to `:dst` failed: :last_error_message', 'dst' => $dst]);
        }

        if (!chmod($this->alias->resolve($dst), 0644)) {
            throw new FileException(['chmod `:dst` destination failed: :last_error_message', 'dst' => $dst]);
        }
    }
971999
public function autoOrient(string $src, string $dst)
    {
        if (!$dst) {
            $dst=$src;
        }
        return $this
        ->image($src)
        ->autoOrient()
        ->toFile($dst);
    }
3930
def extract_tarfile(archive_name, destpath):
    ""
    archive = tarfile.open(archive_name)
    archive.extractall(destpath)
244274
protected static function copyParameterBag(ParameterBag $src, ParameterBag $dst) {
        foreach ($src->keys() as $current) {
            if (true === in_array($current, DataTablesEnumerator::enumParameters())) {
                continue;
            }
            $dst->set($current, $src->get($current));
        }
    }
192774
def extractall(archive, filename, dstdir):
    
    
    if zipfile.is_zipfile(archive):
        z = zipfile.ZipFile(archive)
        for name in z.namelist():
            targetname = name
            # directories ends with '/' (on Windows as well)
            if targetname.endswith('/'):
                targetname = targetname[:-1]

            # don't include leading "/" from file name if present
            if targetname.startswith(os.path.sep):
                targetname = os.path.join(dstdir, targetname[1:])
            else:
                targetname = os.path.join(dstdir, targetname)                
            targetname = os.path.normpath(targetname)

            # Create all upper directories if necessary.    
            upperdirs = os.path.dirname(targetname)
            if upperdirs and not os.path.exists(upperdirs):
                os.makedirs(upperdirs)

            # directories ends with '/' (on Windows as well)
            if not name.endswith('/'):
                # copy file
                file(targetname, 'wb').write(z.read(name))

    elif tarfile.is_tarfile(archive):
        tar = tarfile.open(archive)
        tar.extractall(path=dstdir)
    else:
        # seems to be a single file, save it
        shutil.copyfile(archive, os.path.join(dstdir, filename))
839455
public function dump($dst) {
		$host = $this->config['host'];
		$user = $this->config['user'];
		$pwd = $this->config['password'];
		$db = $this->config['database'];

		\Asgard\File\FileSystem::mkdir(dirname($dst));
		$cmd = 'mysqldump --user='.$user.' --password='.$pwd.' --host='.$host.' '.$db.' > '.$dst;
		$process = proc_open($cmd,
			[
				0 => ["pipe", "r"],
				1 => ["pipe", "w"],
				2 => ["pipe", "w"],
			],
			$pipes
		);
		return proc_close($process) === 0;
	}
847979
protected function extractArchive($archiveFile)
    {
        $archiveDir    = dirname($archiveFile);
        $archiveObj    = new ZipArchive();
        $archiveHandle = $archiveObj->open($archiveFile);
        if (true !== $archiveHandle) {
            return array('error' => __('Could not open archive'));
        }

        if (!$archiveObj->extractTo($archiveDir)) {
            $archiveObj->close();
            return array('error' => __('Could not extract archive'));
        }
        $archiveObj->close();
        return $archiveDir;
    }
936674
private function __copyDir($src, $dst, &$files = null)
    {
        $dir = opendir($src);
        @mkdir($dst);
        while (false !== ($file = readdir($dir))) {
            if (('.' != $file) && ('..' != $file)) {
                if (is_dir($src.'/'.$file)) {
                    $this->__copyDir($src.'/'.$file, $dst.'/'.$file, $files);
                } else {
                    copy($src.'/'.$file, $dst.'/'.$file);
                    if (\is_array($files)) {
                        $files[] = $dst.'/'.$file;
                    }
                }
            }
        }
        closedir($dir);
    }
242711
def extract_archive(archive_path, destination_path):
    """"""
    tar = tarfile.open(archive_path)
    tar.errorlevel = 1
    tar.extractall(destination_path)
782344
public static function recurseCopyIfEdited($src = '', $dst = '', array $excludes = ['php'])
    {
        if (!is_dir($dst) && (!mkdir($dst) && !is_dir($dst))) {
            throw new Exception('Copy dir error, access denied for path: '.$dst);
        }

        $dir = opendir($src);
        if (!$dir) {
            throw new Exception('Unable to read dir: '.$src);
        }

        while (false !== ($file = readdir($dir))) {
            if ($file === '.' || $file === '..') {
                continue;
            }

            if (is_dir($src.'/'.$file)) {
                self::recurseCopyIfEdited($src.'/'.$file, $dst.'/'.$file, $excludes);
                continue;
            }

            if (in_array(substr($file, strrpos($file, '.') + 1), $excludes, null)) {
                continue;
            }


            if (file_exists($dst.'/'.$file) && (filemtime($src.'/'.$file) === filemtime($dst.'/'.$file))) {
                continue;
            }

            copy($src.'/'.$file, $dst.'/'.$file);
            chmod($dst.'/'.$file, 0666);
        }
        closedir($dir);
    }
106879
public static function copyDir($src, $dst, $fileMode = 0644)
    {
        $src = realpath($src);
        if (!is_readable($src)) {
            throw new Exception('Dir ' . $src . ' is not readable');
        }
        if (!is_dir($src)) {
            throw new Exception('' . $src . ' is not a directory');
        }

        if (!file_exists($dst)) {
            self::mkDir($dst);
        }
        $dst = realpath($dst);
        if (!is_readable($dst)) {
            throw new Exception('Dir ' . $dst . ' is not readable');
        }
        if (!is_dir($dst)) {
            throw new Exception('' . $dst . ' is not a directory');
        }

        foreach (self::listDir($src) as $file) {
            $fileName = basename($file);
            if ('.' == $fileName || '..' == $fileName) {
                continue;
            }
            if (!is_readable($file)) {
                throw new Exception($file . ' is not readable');
            }
            if (is_dir($file)) {
                self::copyDir($file, $dst . DS . $fileName);
            } else {
                self::copyFile($file, $dst, $fileMode);
            }
        }
    }
108813
protected function copyFile(string $src, string $dst, bool $compile)
    {
        if (is_file($dst) && !$this->overwrite && !$this->confirmOverwrite) {
            $this->info("File exists and overwrite disabled, skipping {$dst}", OutputInterface::VERBOSITY_VERY_VERBOSE);
        }

        if (!$this->confirmOverwrite($dst)) {
            return;
        }

        $this->info("Copying '{$src}' to '{$dst}'", OutputInterface::VERBOSITY_VERY_VERBOSE);

        file_put_contents($dst, $compile ? $this->compileFile($src) : file_get_contents($src));
    }
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]);
        }
    }