Changeset 378

Show
Ignore:
Timestamp:
07/29/08 15:56:23 (5 months ago)
Author:
mrook
Message:

#259 - Remove warning, whitespace cleanup (patch by mazzarelli AT gmail.com)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/2.3/classes/phing/tasks/ext/UntarTask.php

    r144 r378  
    3030 */ 
    3131class UntarTask extends ExtractBaseTask { 
    32      
     32 
    3333    /** 
    3434     * Ensures that PEAR lib exists. 
     
    4040        } 
    4141    } 
    42      
     42 
    4343    protected function extractArchive(PhingFile $tarfile) 
    4444    { 
    4545        $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           
    5252        } catch (IOException $ioe) { 
    5353            $msg = "Could not extract tar file: " . $ioe->getMessage(); 
     
    5555        } 
    5656    } 
    57      
     57 
    5858    protected function listArchiveContent(PhingFile $tarfile) 
    5959    { 
     
    6161        return $tar->listContent(); 
    6262    } 
    63      
     63 
    6464    /** 
    6565     * Init a Archive_Tar class with correct compression for the given file. 
     
    7272        $compression = null; 
    7373        $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; 
    7883                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            } 
    8685        } 
    87          
    88        return new Archive_Tar($tarfile->getAbsolutePath(), $compression); 
     86 
     87        return new Archive_Tar($tarfile->getAbsolutePath(), $compression); 
    8988    } 
    9089}