示例#1
0
 function ZipFile($fileRef, $referenced = false)
 {
     if (is_int($fileRef)) {
         return parent::FileReference($fileRef, $referenced);
     }
     parent::FileReference($fileRef, $referenced);
     preg_match('/\\.([^.]{2,4}$)/', $fileRef['name'], $m);
     $ext = strtolower($m[1]);
     if ($ext == "zip") {
         $commandLine = "unzip";
     } elseif ($ext == "tar") {
         $commandLine = "tar vxf";
     }
     /* nao funcionou :(
     		elseif ($ext == "gz" || $ext == "tgz")
     			$commandLine = "gunzip";
     		elseif ($ext == "bz2" || $ext == "tbz2")
     			$commandLine = "bunzip2";
     		 TODO quebrar tgz e tbz2 em dois comandos pra contornar o safe_mode
     		elseif ($ext == "tgz")
     			$commandLine = "tar vxzf";
     		elseif ($ext == "tbz2")
     			$commandLine = "tar vxjf";
     		elseif ($ext == "gz") {
     			if (preg_match('/\.tar\.gz$/', $fileRef['name']))
     				$commandLine = "tar vxzf";
     		}
     		elseif ($ext == "bz2") {
     			if (preg_match('/\.tar\.bz2$/', $fileRef['name']))
     				$commandLine = "tar vxjf";
     		}
     		*/
     $this->update(array("commandLine" => $commandLine));
     return $this;
 }