123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
- require_once 'phing/tasks/ext/ExtractBaseTask.php';
- require_once 'phing/system/io/FileSystem.php';
- class UnzipTask extends ExtractBaseTask
- {
-
- 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;
- }
-
-
- protected function listArchiveContent(PhingFile $zipfile)
- {
- $zip = new ZipArchive();
- $zip->open($zipfile->getAbsolutePath());
-
- $content = array();
- for ($i = 0; $i < $zip->numFiles; $i++) {
- $content[] = $zip->getNameIndex($i);
- }
- return $content;
- }
- }
|