read())) { if ($entry != '.' && $entry != '..' && $entry != 'app_modules') { $this->copy_folder("$d1/$entry", "$d2/$entry"); } } $d->close(); } else { copy($d1, $d2); } } public function recursiveRemoveDir($dir): void { $includes = new FilesystemIterator($dir); foreach ($includes as $include) { if(is_dir($include) && !is_link($include)) { $this->recursiveRemoveDir($include); } else { unlink($include); } } rmdir($dir); } public function recursiveRemoveKernelDir(): void { $includes = new FilesystemIterator(KERNEL_DIR); foreach ($includes as $include) { if ($include->getFilename() === 'app_modules') continue; if(is_dir($include) && !is_link($include)) { $this->recursiveRemoveDir($include); } else { unlink($include); } } } public function pack(string $source, string $destination/*, bool $include_source = true*/): void { $zip = new ZipArchive(); $zip->open($destination, ZipArchive::CREATE | ZipArchive::OVERWRITE); if (is_file($source)) { $zip->addFile(basename($source)); } if (is_dir($source)) { $this->recursiveAddFile($zip, $source); } $zip->close(); } private function recursiveAddFile(ZipArchive $zip, string $dir, string $folder = ''): void { $includes = new FilesystemIterator($dir); foreach ($includes as $include) { if(is_dir($include)) { if ($include->getFilename() === 'app_modules') continue; $tmpFolder = $folder . '/' . $include->getFilename(); $this->recursiveAddFile($zip, $include, $tmpFolder); } if (is_file($include)) { $zip->addFile($include->getPathName(), $folder . "/" . $include->getFilename()); } } } }