Changeset 378 for branches/2.3
- Timestamp:
- 07/29/08 15:56:23 (4 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/2.3/classes/phing/tasks/ext/UntarTask.php
r144 r378 30 30 */ 31 31 class UntarTask extends ExtractBaseTask { 32 32 33 33 /** 34 34 * Ensures that PEAR lib exists. … … 40 40 } 41 41 } 42 42 43 43 protected function extractArchive(PhingFile $tarfile) 44 44 { 45 45 $this->log("Extracting tar file: " . $tarfile->__toString() . ' to ' . $this->todir->__toString(), Project::MSG_INFO); 46 47 try {48 $tar = $this->initTar($tarfile);49 if(!$tar->extractModify($this->todir->getAbsolutePath(), $this->removepath)) {50 throw new BuildException('Failed to extract tar file: ' . $tarfile->getAbsolutePath());51 }46 47 try { 48 $tar = $this->initTar($tarfile); 49 if(!$tar->extractModify($this->todir->getAbsolutePath(), $this->removepath)) { 50 throw new BuildException('Failed to extract tar file: ' . $tarfile->getAbsolutePath()); 51 } 52 52 } catch (IOException $ioe) { 53 53 $msg = "Could not extract tar file: " . $ioe->getMessage(); … … 55 55 } 56 56 } 57 57 58 58 protected function listArchiveContent(PhingFile $tarfile) 59 59 { … … 61 61 return $tar->listContent(); 62 62 } 63 63 64 64 /** 65 65 * Init a Archive_Tar class with correct compression for the given file. … … 72 72 $compression = null; 73 73 $tarfileName = $tarfile->getName(); 74 $mode = substr($tarfileName, strrpos($tarfileName, '.')); 75 switch($mode) { 76 case '.gz': 77 $compression = 'gz'; 74 $mode = strtolower(substr($tarfileName, strrpos($tarfileName, '.'))); 75 76 $compressions = array( 77 'gz' => array('.gz', '.tgz',), 78 'bz2' => array('.bz2',), 79 ); 80 foreach ($compressions as $algo => $ext) { 81 if (array_search($mode, $ext) !== false) { 82 $compression = $algo; 78 83 break; 79 case '.bz2': 80 $compression = 'bz2'; 81 break; 82 case '.tar': 83 break; 84 default: 85 $this->log('Ignoring unknown compression mode: ' . $mode, Project::MSG_WARN); 84 } 86 85 } 87 88 return new Archive_Tar($tarfile->getAbsolutePath(), $compression);86 87 return new Archive_Tar($tarfile->getAbsolutePath(), $compression); 89 88 } 90 89 }
