Beispiel #1
0
 /**
  * @param string $file
  * @param bool $location
  * @return bool
  */
 public static function unpack($file, $loc = false)
 {
     $t = new Tar();
     if (!$t->openTar(self::normalizePath($file))) {
         return false;
     }
     if (!$loc) {
         return $t->files;
     }
     if (!file_exists(self::normalizePath($loc))) {
         mkdir($loc, 0777, true);
     }
     if (substr($loc, 0, -1) != '/') {
         $loc .= '/';
     }
     foreach ($t->files as $file) {
         if (!file_exists(self::normalizePath($loc . dirname($file['name'])))) {
             mkdir(self::normalizePath($loc . dirname($file['name'])), 0777, true);
         }
         file_put_contents(self::normalizePath($loc . $file['name']), $file['file']);
         chmod(self::normalizePath($loc . $file['name']), 0777);
     }
     return true;
 }