public function testZipDirectory() { $objFileSystem = new class_filesystem(); echo "\t creating test structure\n"; $objFileSystem->folderCreate("/files/cache/ziptest"); $this->assertFileExists(_realpath_ . "/files/cache/ziptest", __FILE__ . " checkFileNotExists"); $objFileSystem->folderCreate("/files/cache/ziptest/subdir"); $objFileSystem->fileCopy(class_resourceloader::getInstance()->getCorePathForModule("module_system") . "/module_system/metadata.xml", "/files/cache/ziptest/licence_lgpl1.txt"); $objFileSystem->fileCopy(class_resourceloader::getInstance()->getCorePathForModule("module_system") . "/module_system/metadata.xml", "/files/cache/ziptest/licence_lgpl2.txt"); $objFileSystem->fileCopy(class_resourceloader::getInstance()->getCorePathForModule("module_system") . "/module_system/metadata.xml", "/files/cache/ziptest/subdir/licence_lgpl.txt"); echo "\ttesting class_zip...\n"; $objZip = new class_zip(); echo "\topening test.zip\n"; $this->assertTrue($objZip->openArchiveForWriting("/files/cache/test.zip"), __FILE__ . " openArchive"); $this->assertTrue($objZip->addFolder("/files/cache/ziptest"), __FILE__ . " addFolder"); $this->assertTrue($objZip->closeArchive(), __FILE__ . " closeArchive"); $this->assertFileExists(_realpath_ . "/files/cache/test.zip", __FILE__ . " checkFileExists"); echo "\textracting files\n"; $objFileSystem->folderCreate("/files/cache/zipextract"); $this->assertFileExists(_realpath_ . "/files/cache/zipextract", __FILE__ . " checkFileExists"); $objZip = new class_zip(); $this->assertTrue($objZip->extractArchive("/files/cache/test.zip", "/files/cache/zipextract"), __FILE__ . " extractArchive"); $this->assertFileExists(_realpath_ . "/files/cache/zipextract/files/cache/ziptest/licence_lgpl1.txt", __FILE__ . " extractArchive"); $this->assertFileExists(_realpath_ . "/files/cache/zipextract/files/cache/ziptest/licence_lgpl2.txt", __FILE__ . " extractArchive"); $this->assertFileExists(_realpath_ . "/files/cache/zipextract/files/cache/ziptest/subdir/licence_lgpl.txt", __FILE__ . " extractArchive"); echo "\tremoving testfile\n"; $this->assertTrue($objFileSystem->fileDelete("/files/cache/test.zip"), __FILE__ . " deleteFile"); $this->assertFileNotExists(_realpath_ . "/files/cache/test.zip", __FILE__ . " checkFileNotExists"); $objFileSystem->folderDeleteRecursive("/files/cache/ziptest"); $this->assertFileNotExists(_realpath_ . "/files/cache/ziptest", __FILE__ . " checkFileNotExists"); $objFileSystem->folderDeleteRecursive("/files/cache/zipextract"); $this->assertFileNotExists(_realpath_ . "/files/cache/zipextract", __FILE__ . " checkFileNotExists"); }
/** * Extracts the zip-archive into a temp-folder. * The matching packagemanager is returned. * * @param string $strPackagePath * * @return interface_packagemanager_packagemanager */ public function extractPackage($strPackagePath) { $strTargetFolder = generateSystemid(); class_logger::getInstance(class_logger::PACKAGEMANAGEMENT)->addLogRow("extracting package " . $strPackagePath . " to " . _projectpath_ . "/temp/" . $strTargetFolder, class_logger::$levelInfo); $objZip = new class_zip(); $objZip->extractArchive($strPackagePath, _projectpath_ . "/temp/" . $strTargetFolder); return $this->getPackageManagerForPath(_projectpath_ . "/temp/" . $strTargetFolder); }