示例#1
0
 /**
 Extract zip file in current location
 
 @param	f		<b>fileRecord</b>	fileRecord object
 */
 public function inflateZipFile($f, $create_dir = true)
 {
     $zip = new fileUnzip($f->file);
     $zip->setExcludePattern($this->exclude_pattern);
     $zip->getList(false, '#(^|/)(__MACOSX|\\.svn|\\.DS_Store|\\.directory|Thumbs\\.db)(/|$)#');
     if ($create_dir) {
         $zip_root_dir = $zip->getRootDir();
         if ($zip_root_dir != false) {
             $destination = $zip_root_dir;
             $target = $f->dir;
         } else {
             $destination = preg_replace('/\\.([^.]+)$/', '', $f->basename);
             $target = $f->dir . '/' . $destination;
         }
         if (is_dir($f->dir . '/' . $destination)) {
             throw new Exception(sprintf(__('Extract destination directory %s already exists.'), dirname($f->relname) . '/' . $destination));
         }
     } else {
         $target = $f->dir;
         $destination = '';
     }
     $zip->unzipAll($target);
     $zip->close();
     return dirname($f->relname) . '/' . $destination;
 }