Skip to content

Commit 503a01a

Browse files
authored
Merge pull request #26 from wirecli/use-ziparchive-in-newcommand-7746076139456589807
Use ZipArchive class for profile extraction in NewCommand
2 parents 35cfacc + db00816 commit 503a01a

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

‎src/Commands/Common/NewCommand.php‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Wirecli\Helpers\Installer;
1616
use Wirecli\Helpers\PwConnector;
1717
use Wirecli\Helpers\WsTools as Tools;
18+
use ZipArchive;
1819

1920
/**
2021
* Class NewCommand
@@ -650,8 +651,15 @@ private function extractProfile($profile) {
650651

651652
try {
652653
$extractPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid(time()) . DIRECTORY_SEPARATOR;
653-
// TODO: use Symfony ZipArchive class
654-
//$extractionSucceeded = $distill->extractWithoutRootDirectory($profile, $extractPath);
654+
$this->fs->mkdir($extractPath);
655+
656+
$zip = new ZipArchive;
657+
$extractionSucceeded = false;
658+
659+
if ($zip->open($profile) === TRUE) {
660+
$extractionSucceeded = $zip->extractTo($extractPath);
661+
$zip->close();
662+
}
655663

656664
foreach (new \DirectoryIterator($extractPath) as $fileInfo) {
657665
if ($fileInfo->isDir() && !$fileInfo->isDot()) {

0 commit comments

Comments
 (0)