当前位置: 首页>>代码示例>>PHP>>正文


PHP Archive_Tar::setErrorHandling方法代码示例

本文整理汇总了PHP中Archive_Tar::setErrorHandling方法的典型用法代码示例。如果您正苦于以下问题:PHP Archive_Tar::setErrorHandling方法的具体用法?PHP Archive_Tar::setErrorHandling怎么用?PHP Archive_Tar::setErrorHandling使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Archive_Tar的用法示例。


在下文中一共展示了Archive_Tar::setErrorHandling方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create

 /**
  * @param	string	The name of the archive
  * @param	mixed	The name of a single file or an array of files
  * @param	string	The compression for the archive
  * @param	string	Path to add within the archive
  * @param	string	Path to remove within the archive
  * @param	boolean	Automatically append the extension for the archive
  * @param	boolean	Remove for source files
  */
 function create($archive, $files, $compress = 'tar', $addPath = '', $removePath, $autoExt = true)
 {
     $compress = strtolower($compress);
     if ($compress == 'tgz' || $compress == 'tbz' || $compress == 'tar') {
         require_once _EXT_PATH . '/libraries/Tar.php';
         if (is_string($files)) {
             $files = array($files);
         }
         if ($autoExt) {
             $archive .= '.' . $compress;
         }
         if ($compress == 'tgz') {
             $compress = 'gz';
         }
         if ($compress == 'tbz') {
             $compress = 'bz2';
         }
         $tar = new Archive_Tar($archive, $compress);
         $tar->setErrorHandling(PEAR_ERROR_PRINT);
         $result = $tar->addModify($files, $addPath, $removePath);
         return $result;
     } elseif ($compress == 'zip') {
         $adapter =& xFileArchive::getAdapter('zip');
         if ($adapter) {
             $result = $adapter->create($archive, $files, $removePath);
         }
         if ($result == false) {
             return PEAR::raiseError('Unrecoverable ZIP Error');
         }
     }
 }
开发者ID:xamiro-dev,项目名称:xamiro,代码行数:40,代码来源:archive.php

示例2: expand

 public static function expand($path)
 {
     $path = realpath($path);
     $dir = dirname($path);
     #print ">> $path\n";
     $arch = new Archive_Tar($path, true);
     $arch->setErrorHandling(PEAR_ERROR_PRINT);
     if (false === $arch->extract($dir)) {
         throw new Pfw_Exception_Script(Pfw_Exception_Script::E_ARCHIVE_UNKNOWN);
     }
 }
开发者ID:seansitter,项目名称:picnicphp,代码行数:11,代码来源:Archive.php

示例3: install

 static function install($source, $filename)
 {
     $target = SIMPLE_EXT . substr($filename, 0, -3);
     setup::out("{t}Download{/t}: " . $source . " ...");
     if ($fz = gzopen($source, "r") and $fp = fopen($target, "w")) {
         $i = 0;
         while (!gzeof($fz)) {
             $i++;
             setup::out(".", false);
             if ($i % 160 == 0) {
                 setup::out();
             }
             fwrite($fp, gzread($fz, 16384));
         }
         gzclose($fz);
         fclose($fp);
     } else {
         sys_die("{t}Error{/t}: gzopen [2] " . $source);
     }
     setup::out();
     if (!file_exists($target) or filesize($target) == 0 or filesize($target) % 10240 != 0) {
         sys_die("{t}Error{/t}: file-check [3] Filesize: " . filesize($target) . " " . $target);
     }
     setup::out(sprintf("{t}Processing %s ...{/t}", basename($target)));
     $tar_object = new Archive_Tar($target);
     $tar_object->setErrorHandling(PEAR_ERROR_PRINT);
     $tar_object->extract(SIMPLE_EXT);
     $file_list = $tar_object->ListContent();
     if (!is_array($file_list) or !isset($file_list[0]["filename"]) or !is_dir(SIMPLE_EXT . $file_list[0]["filename"])) {
         sys_die("{t}Error{/t}: tar [4] " . $target);
     }
     self::update_modules_list();
     $ext_folder = db_select_value("simple_sys_tree", "id", "anchor=@anchor@", array("anchor" => "extensions"));
     foreach ($file_list as $file) {
         sys_chmod(SIMPLE_EXT . $file["filename"]);
         setup::out(sprintf("{t}Processing %s ...{/t}", SIMPLE_EXT . $file["filename"]));
         if (basename($file["filename"]) == "install.php") {
             setup::out("");
             require SIMPLE_EXT . $file["filename"];
             setup::out("");
         }
         if (basename($file["filename"]) == "readme.txt") {
             $data = file_get_contents(SIMPLE_EXT . $file["filename"]);
             setup::out(nl2br("\n" . q($data) . "\n"));
         }
         if (!empty($ext_folder) and basename($file["filename"]) == "folders.xml") {
             setup::out(sprintf("{t}Processing %s ...{/t}", "folder structure"));
             folders::create_default_folders(SIMPLE_EXT . $file["filename"], $ext_folder, false);
         }
     }
 }
开发者ID:drognisep,项目名称:Simple-Groupware,代码行数:51,代码来源:extensions.php

示例4: extract

 static function extract($target, $folder)
 {
     setup::out(sprintf("{t}Processing %s ...{/t}", basename($target)));
     $tar_object = new Archive_Tar($target);
     $tar_object->setErrorHandling(PEAR_ERROR_PRINT);
     $tar_object->extract($folder);
     $file_list = $tar_object->ListContent();
     if (!is_array($file_list) or !isset($file_list[0]["filename"]) or !is_dir($folder . $file_list[0]["filename"])) {
         sys_die("{t}Error{/t}: tar [3] " . $target);
     }
     foreach ($file_list as $file) {
         sys_chmod($folder . $file["filename"]);
     }
     @unlink($target);
     return $folder . $file_list[0]["filename"];
 }
开发者ID:drognisep,项目名称:Simple-Groupware,代码行数:16,代码来源:updater.php

示例5: nc_tgz_create

function nc_tgz_create($archive_name, $file_name, $additional_path = '', $exclude_tag = NULL)
{
    global $DOCUMENT_ROOT, $SUB_FOLDER;
    @set_time_limit(0);
    $path = $DOCUMENT_ROOT . $SUB_FOLDER . $additional_path;
    if (SYSTEM_TAR) {
        $exclude_tag_cmd = '';
        if ($exclude_tag) {
            $exclude_array_tmp = nc_exclude_tag_to_array($path, $exclude_tag);
            $exclude_array = array();
            foreach ($exclude_array_tmp as $item) {
                $exclude_array[] = '--exclude=' . preg_quote(ltrim(substr($item, strlen($path)), '/'));
            }
            $exclude_tag_cmd = implode(' ', $exclude_array);
        }
        exec("cd {$path}; tar -zcf '{$archive_name}' {$exclude_tag_cmd} {$file_name} 2>&1", $output, $err_code);
        if ($err_code) {
            trigger_error("{$output['0']}", E_USER_WARNING);
            return false;
        }
        return true;
    } else {
        $tar_object = new Archive_Tar($archive_name, "gz");
        $tar_object->setErrorHandling(PEAR_ERROR_PRINT);
        if ($exclude_tag) {
            $exclude_array_tmp = nc_exclude_tag_to_array($path, $exclude_tag);
            $exclude_array = array();
            foreach ($exclude_array_tmp as $item) {
                $exclude_array[] = ltrim(substr($item, strlen($path)), '/');
            }
            $tar_object->setIgnoreList($exclude_array);
        }
        chdir($path);
        ob_start();
        $file_name_array = explode(' ', $file_name);
        $res = $tar_object->create($file_name_array);
        if (!$res) {
            ob_end_flush();
        } else {
            ob_end_clean();
        }
        return $res;
    }
}
开发者ID:Blu2z,项目名称:implsk,代码行数:44,代码来源:tar.inc.php

示例6: foreach

 function _generateTarFile($compress = true)
 {
     $pkgver = (string) $this->xml->name . '-' . (string) $this->xml->version->release;
     $targetdir = !empty($this->options['targetdir']) ? $this->options['targetdir'] . DIRECTORY_SEPARATOR : '';
     $tarname = $targetdir . $pkgver . ($compress ? '.tgz' : '.tar');
     $tar = new Archive_Tar($tarname, $compress);
     $tar->setErrorHandling(PEAR_ERROR_RETURN);
     $result = $tar->create(array($this->pkginfofile));
     if (PEAR::isError($result)) {
         return $this->raiseError($result);
     }
     foreach ($this->files as $roleDir => $files) {
         $result = $tar->addModify($files, $pkgver, $roleDir);
     }
     if (PEAR::isError($result)) {
         return $this->raiseError($result);
     }
     $this->output .= 'Successfully created ' . $tarname . "\n";
     return true;
 }
开发者ID:codercv,项目名称:urbansurprisedev,代码行数:20,代码来源:Mage.php

示例7: message

 function Create_Tar($which_exported, $add_dirs)
 {
     global $dataDir, $langmessage;
     if (!$this->NewFile($which_exported, 'tar')) {
         return;
     }
     $this->Init_Tar();
     //$tar_object = new Archive_Tar($this->archive_path,'gz'); //didn't always work when compressin
     $tar_object = new Archive_Tar($this->archive_path);
     if (gpdebug) {
         $tar_object->setErrorHandling(PEAR_ERROR_PRINT);
     }
     if (!$tar_object->createModify($add_dirs, 'gpexport', $dataDir)) {
         message($langmessage['OOPS'] . '(5)');
         unlink($this->archive_path);
         return false;
     }
     //add in array so addModify doesn't split the string into an array
     $temp = array();
     $temp[] = $this->export_ini_file;
     if (!$tar_object->addModify($temp, 'gpexport', $this->temp_dir)) {
         message($langmessage['OOPS'] . '(6)');
         unlink($this->archive_path);
         return false;
     }
     //compression
     $compression =& $_POST['compression'];
     if (!isset($this->avail_compress[$compression])) {
         return true;
     }
     $new_path = $this->archive_path . '.' . $compression;
     $new_name = $this->archive_name . '.' . $compression;
     switch ($compression) {
         case 'gz':
             //gz compress the tar
             $gz_handle = @gzopen($new_path, 'wb9');
             if (!$gz_handle) {
                 return true;
             }
             if (!@gzwrite($gz_handle, file_get_contents($this->archive_path))) {
                 return true;
             }
             @gzclose($gz_handle);
             break;
         case 'bz':
             //gz compress the tar
             $bz_handle = @bzopen($new_path, 'w');
             if (!$bz_handle) {
                 return true;
             }
             if (!@bzwrite($bz_handle, file_get_contents($this->archive_path))) {
                 return true;
             }
             @bzclose($bz_handle);
             break;
     }
     unlink($this->archive_path);
     $this->archive_path = $new_path;
     $this->archive_name = $new_name;
     return true;
 }
开发者ID:rizub4u,项目名称:gpEasy-CMS,代码行数:61,代码来源:admin_port.php

示例8: main

 /**
  * do the work
  * @throws BuildException
  */
 public function main()
 {
     if ($this->tarFile === null) {
         throw new BuildException("tarfile attribute must be set!", $this->getLocation());
     }
     if ($this->tarFile->exists() && $this->tarFile->isDirectory()) {
         throw new BuildException("tarfile is a directory!", $this->getLocation());
     }
     if ($this->tarFile->exists() && !$this->tarFile->canWrite()) {
         throw new BuildException("Can not write to the specified tarfile!", $this->getLocation());
     }
     // shouldn't need to clone, since the entries in filesets
     // themselves won't be modified -- only elements will be added
     $savedFileSets = $this->filesets;
     try {
         if ($this->baseDir !== null) {
             if (!$this->baseDir->exists()) {
                 throw new BuildException("basedir '" . (string) $this->baseDir . "' does not exist!", $this->getLocation());
             }
             if (empty($this->filesets)) {
                 // if there weren't any explicit filesets specivied, then
                 // create a default, all-inclusive fileset using the specified basedir.
                 $mainFileSet = new TarFileSet($this->fileset);
                 $mainFileSet->setDir($this->baseDir);
                 $this->filesets[] = $mainFileSet;
             }
         }
         if (empty($this->filesets)) {
             throw new BuildException("You must supply either a basedir " . "attribute or some nested filesets.", $this->getLocation());
         }
         // check if tar is out of date with respect to each fileset
         if ($this->tarFile->exists()) {
             $upToDate = true;
             foreach ($this->filesets as $fs) {
                 $files = $fs->getFiles($this->project, $this->includeEmpty);
                 if (!$this->archiveIsUpToDate($files, $fs->getDir($this->project))) {
                     $upToDate = false;
                 }
                 for ($i = 0, $fcount = count($files); $i < $fcount; $i++) {
                     if ($this->tarFile->equals(new PhingFile($fs->getDir($this->project), $files[$i]))) {
                         throw new BuildException("A tar file cannot include itself", $this->getLocation());
                     }
                 }
             }
             if ($upToDate) {
                 $this->log("Nothing to do: " . $this->tarFile->__toString() . " is up to date.", Project::MSG_INFO);
                 return;
             }
         }
         $this->log("Building tar: " . $this->tarFile->__toString(), Project::MSG_INFO);
         $tar = new Archive_Tar($this->tarFile->getAbsolutePath(), $this->compression);
         // print errors
         $tar->setErrorHandling(PEAR_ERROR_PRINT);
         foreach ($this->filesets as $fs) {
             $files = $fs->getFiles($this->project, $this->includeEmpty);
             if (count($files) > 1 && strlen($fs->getFullpath()) > 0) {
                 throw new BuildException("fullpath attribute may only " . "be specified for " . "filesets that specify a " . "single file.");
             }
             $fsBasedir = $fs->getDir($this->project);
             $filesToTar = array();
             for ($i = 0, $fcount = count($files); $i < $fcount; $i++) {
                 $f = new PhingFile($fsBasedir, $files[$i]);
                 $filesToTar[] = $f->getAbsolutePath();
                 $this->log("Adding file " . $f->getPath() . " to archive.", Project::MSG_VERBOSE);
             }
             $tar->addModify($filesToTar, $this->prefix, $fsBasedir->getAbsolutePath());
         }
     } catch (IOException $ioe) {
         $msg = "Problem creating TAR: " . $ioe->getMessage();
         $this->filesets = $savedFileSets;
         throw new BuildException($msg, $ioe, $this->getLocation());
     }
     $this->filesets = $savedFileSets;
 }
开发者ID:sergeytsivin,项目名称:haru,代码行数:78,代码来源:TarTask.php

示例9: trim

$BASE_VERSION = trim(shell_exec('grep -m 1 \'<version>.*</version>\' *.xml | sed s/.*\\<version\\>// | sed s/\\<\\\\/version\\>.*//'));
if (!$BASE_VERSION || strpos($BASE_VERSION, "\n") !== false) {
    I2CE::raiseError("Unable to determine base version", E_USER_ERROR);
}
if (count(explode('.', $BASE_VERSION)) < 3) {
    I2CE::raiseError("Bad version {$BASE_VERSION}");
}
I2CE::raiseError("Base version is {$BASE_VERSION}");
$BASE_VERSION_SHORT = implode('.', array_slice(explode('.', $BASE_VERSION), 0, 2));
$BASE_VERSION_SHORT_NEXT = array_slice(explode('.', $BASE_VERSION), 0, 2);
$BASE_VERSION_SHORT_NEXT[1]++;
$BASE_VERSION_SHORT_NEXT = implode('.', $BASE_VERSION_SHORT_NEXT);
if (!$booleans['read_po_files']) {
    I2CE::raiseError("Using archive: " . realpath($archive));
    $tar = new Archive_Tar($archive);
    $tar->setErrorHandling(PEAR_ERROR_CALLBACK, array('I2CE', 'raiseError'));
    $tar_files = array();
    $tar_dirs = array();
    $files = $tar->listContent();
    foreach ($files as $data) {
        if (!array_key_exists('filename', $data)) {
            continue;
        }
        if ($data['typeflag'] == 5) {
            $tar_dirs[] = $data['filename'];
        } else {
            if ($data['typeflag'] == 0) {
                $tar_files[] = $data['filename'];
            }
        }
    }
开发者ID:apelon-ohie,项目名称:ihris-site,代码行数:31,代码来源:translate_templates.php

示例10: basename


//.........这里部分代码省略.........
         // bundles of packages
         $contents = $contents['bundledpackage'];
         if (!isset($contents[0])) {
             $contents = array($contents);
         }
         $packageDir = $where;
         foreach ($contents as $i => $package) {
             $fname = $package;
             $file = $pkgdir . DIRECTORY_SEPARATOR . $fname;
             if (!file_exists($file)) {
                 return $packager->raiseError("File does not exist: {$fname}");
             }
             $tfile = $packageDir . DIRECTORY_SEPARATOR . $fname;
             System::mkdir(array('-p', dirname($tfile)));
             copy($file, $tfile);
             $filelist[$i++] = $tfile;
             $packager->log(2, "Adding package {$fname}");
         }
     } else {
         // normal packages
         $contents = $contents['dir']['file'];
         if (!isset($contents[0])) {
             $contents = array($contents);
         }
         $packageDir = $where;
         foreach ($contents as $i => $file) {
             $fname = $file['attribs']['name'];
             $atts = $file['attribs'];
             $orig = $file;
             $file = $pkgdir . DIRECTORY_SEPARATOR . $fname;
             if (!file_exists($file)) {
                 return $packager->raiseError("File does not exist: {$fname}");
             }
             $origperms = fileperms($file);
             $tfile = $packageDir . DIRECTORY_SEPARATOR . $fname;
             unset($orig['attribs']);
             if (count($orig)) {
                 // file with tasks
                 // run any package-time tasks
                 $contents = file_get_contents($file);
                 foreach ($orig as $tag => $raw) {
                     $tag = str_replace(array($this->_packagefile->getTasksNs() . ':', '-'), array('', '_'), $tag);
                     $task = "PEAR_Task_{$tag}";
                     $task = new $task($this->_packagefile->_config, $this->_packagefile->_logger, PEAR_TASK_PACKAGE);
                     $task->init($raw, $atts, null);
                     $res = $task->startSession($this->_packagefile, $contents, $tfile);
                     if (!$res) {
                         continue;
                         // skip this task
                     }
                     if (PEAR::isError($res)) {
                         return $res;
                     }
                     $contents = $res;
                     // save changes
                     System::mkdir(array('-p', dirname($tfile)));
                     $wp = fopen($tfile, "wb");
                     fwrite($wp, $contents);
                     fclose($wp);
                 }
             }
             if (!file_exists($tfile)) {
                 System::mkdir(array('-p', dirname($tfile)));
                 copy($file, $tfile);
             }
             chmod($tfile, $origperms);
             $filelist[$i++] = $tfile;
             $this->_packagefile->setFileAttribute($fname, 'md5sum', md5_file($tfile), $i - 1);
             $packager->log(2, "Adding file {$fname}");
         }
     }
     // }}}
     $name = $pf1 !== null ? 'package2.xml' : 'package.xml';
     $packagexml = $this->toPackageFile($where, PEAR_VALIDATE_PACKAGING, $name);
     if ($packagexml) {
         $tar = new Archive_Tar($dest_package, $compress);
         $tar->setErrorHandling(PEAR_ERROR_RETURN);
         // XXX Don't print errors
         // ----- Creates with the package.xml file
         $ok = $tar->createModify(array($packagexml), '', $where);
         if (PEAR::isError($ok)) {
             return $packager->raiseError($ok);
         } elseif (!$ok) {
             return $packager->raiseError('PEAR_Packagefile_v2::toTgz(): adding ' . $name . ' failed');
         }
         // ----- Add the content of the package
         if (!$tar->addModify($filelist, $pkgver, $where)) {
             return $packager->raiseError('PEAR_Packagefile_v2::toTgz(): tarball creation failed');
         }
         // add the package.xml version 1.0
         if ($pf1 !== null) {
             $pfgen =& $pf1->getDefaultGenerator();
             $packagexml1 = $pfgen->toPackageFile($where, PEAR_VALIDATE_PACKAGING, 'package.xml', true);
             if (!$tar->addModify(array($packagexml1), '', $where)) {
                 return $packager->raiseError('PEAR_Packagefile_v2::toTgz(): adding package.xml failed');
             }
         }
         return $dest_package;
     }
 }
开发者ID:michabbb,项目名称:pear-core,代码行数:101,代码来源:v2.php

示例11: toTgz

 /**
  * @param PEAR_Packager
  * @param bool if true, a .tgz is written, otherwise a .tar is written
  * @param string|null directory in which to save the .tgz
  * @return string|PEAR_Error location of package or error object
  */
 function toTgz(&$packager, $compress = true, $where = null)
 {
     require_once 'Archive/Tar.php';
     if ($where === null) {
         if (!($where = System::mktemp(array('-d')))) {
             return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: mktemp failed');
         }
     } elseif (!@System::mkDir(array('-p', $where))) {
         return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: "' . $where . '" could' . ' not be created');
     }
     if (file_exists($where . DIRECTORY_SEPARATOR . 'package.xml') && !is_file($where . DIRECTORY_SEPARATOR . 'package.xml')) {
         return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: unable to save package.xml as' . ' "' . $where . DIRECTORY_SEPARATOR . 'package.xml"');
     }
     if (!$this->_packagefile->validate(PEAR_VALIDATE_PACKAGING)) {
         return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: invalid package file');
     }
     $pkginfo = $this->_packagefile->getArray();
     $ext = $compress ? '.tgz' : '.tar';
     $pkgver = $pkginfo['package'] . '-' . $pkginfo['version'];
     $dest_package = getcwd() . DIRECTORY_SEPARATOR . $pkgver . $ext;
     if (file_exists(getcwd() . DIRECTORY_SEPARATOR . $pkgver . $ext) && !is_file(getcwd() . DIRECTORY_SEPARATOR . $pkgver . $ext)) {
         return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: cannot create tgz file "' . getcwd() . DIRECTORY_SEPARATOR . $pkgver . $ext . '"');
     }
     if ($pkgfile = $this->_packagefile->getPackageFile()) {
         $pkgdir = dirname(realpath($pkgfile));
         $pkgfile = basename($pkgfile);
     } else {
         return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: package file object must ' . 'be created from a real file');
     }
     // {{{ Create the package file list
     $filelist = array();
     $i = 0;
     foreach ($this->_packagefile->getFilelist() as $fname => $atts) {
         $file = $pkgdir . DIRECTORY_SEPARATOR . $fname;
         if (!file_exists($file)) {
             return PEAR::raiseError("File does not exist: {$fname}");
         } else {
             $filelist[$i++] = $file;
             if (!isset($atts['md5sum'])) {
                 $this->_packagefile->setFileAttribute($fname, 'md5sum', md5_file($file));
             }
             $packager->log(2, "Adding file {$fname}");
         }
     }
     // }}}
     $packagexml = $this->toPackageFile($where, PEAR_VALIDATE_PACKAGING, 'package.xml', true);
     if ($packagexml) {
         $tar = new Archive_Tar($dest_package, $compress);
         $tar->setErrorHandling(PEAR_ERROR_RETURN);
         // XXX Don't print errors
         // ----- Creates with the package.xml file
         $ok = $tar->createModify(array($packagexml), '', $where);
         if (PEAR::isError($ok)) {
             return $ok;
         } elseif (!$ok) {
             return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: tarball creation failed');
         }
         // ----- Add the content of the package
         if (!$tar->addModify($filelist, $pkgver, $pkgdir)) {
             return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: tarball creation failed');
         }
         return $dest_package;
     }
 }
开发者ID:crazy-max,项目名称:neard-bin-php,代码行数:70,代码来源:v1.php

示例12: extractArchive

 /**
  * Extracts the package archive file
  * @return boolean True on success, False on error
  */
 function extractArchive()
 {
     global $_CB_framework;
     $base_Dir = _cbPathName($_CB_framework->getCfg('tmp_path'));
     $archivename = $this->installArchive();
     $tmpdir = uniqid('install_');
     $extractdir = _cbPathName($base_Dir . $tmpdir);
     $archivename = _cbPathName($archivename, false);
     $this->unpackDir($extractdir);
     if (preg_match("/\\.zip\$/i", $archivename)) {
         // Extract functions
         cbimport('pcl.pclziplib');
         $zipfile = new PclZip($archivename);
         if ($this->isWindows()) {
             define('OS_WINDOWS', 1);
         } else {
             define('OS_WINDOWS', 0);
         }
         $ret = $zipfile->extract(PCLZIP_OPT_PATH, $extractdir);
         if ($ret == 0) {
             $this->setError(1, 'Unrecoverable error "' . $zipfile->errorName(true) . '"');
             return false;
         }
     } else {
         cbimport('pcl.tar');
         // includes/Archive/Tar.php' );
         $archive = new Archive_Tar($archivename);
         $archive->setErrorHandling(PEAR_ERROR_PRINT);
         if (!$archive->extractModify($extractdir, '')) {
             $this->setError(1, 'Extract Error');
             return false;
         }
     }
     $this->installDir($extractdir);
     // Try to find the correct install dir. in case that the package have subdirs
     // Save the install dir for later cleanup
     $filesindir = cbReadDirectory($this->installDir(), '');
     if (count($filesindir) == 1) {
         if (is_dir($extractdir . $filesindir[0])) {
             $this->installDir(_cbPathName($extractdir . $filesindir[0]));
         }
     }
     return true;
 }
开发者ID:rogatnev-nikita,项目名称:cloudinterpreter,代码行数:48,代码来源:cb.installer.php

示例13: extractArchive

function extractArchive($filename)
{
    $absolute_path = JPATH_ROOT;
    $base_Dir = $absolute_path . '/tmp/';
    $archivename = $base_Dir . $filename;
    $tmpdir = uniqid('install_');
    $extractdir = $base_Dir . $tmpdir;
    //$archivename 	= mosPathName( $archivename;
    //echo $archivename;
    //$this->unpackDir( $extractdir );
    if (preg_match('/.zip$/', $archivename)) {
        // Extract functions
        require_once $absolute_path . '/administrator/components/com_swmenufree/pcl/pclzip.lib.php';
        require_once $absolute_path . '/administrator/components/com_swmenufree/pcl/pclerror.lib.php';
        require_once $absolute_path . '/administrator/components/com_swmenufree/pcl/pcltrace.lib.php';
        //require_once( $absolute_path . '/administrator/includes/pcl/pcltar.lib.php' );
        $zipfile = new PclZip($archivename);
        //if($this->isWindows()) {
        //		define('OS_WINDOWS',1);
        //	} else {
        //		define('OS_WINDOWS',0);
        //	}
        $ret = $zipfile->extract(PCLZIP_OPT_PATH, $extractdir);
        if ($ret == 0) {
            //$this->setError( 1, 'Unrecoverable error "'.$zipfile->errorName(true).'"' );
            return false;
        }
    } else {
        require_once $absolute_path . '/administrator/components/com_swmenufree/pcl/Tar.php';
        $archive = new Archive_Tar($archivename);
        $archive->setErrorHandling(PEAR_ERROR_PRINT);
        if (!$archive->extractModify($extractdir, '')) {
            $this->setError(1, 'Extract Error');
            return false;
        }
    }
    return $extractdir;
}
开发者ID:shamusdougan,项目名称:GDMCWebsite,代码行数:38,代码来源:swmenufree.php

示例14: extract_tar

function extract_tar($filename, $dirName)
{
    if (class_exists('PharData')) {
        try {
            $phar = new PharData($filename);
            $phar->extractTo($dirName);
        } catch (Exception $e) {
            return false;
        }
        return true;
    }
    $tar = new Archive_Tar($filename);
    $tar->setErrorHandling(PEAR_ERROR_PRINT);
    return $tar->extract($dirName);
}
开发者ID:kitware,项目名称:cdash,代码行数:15,代码来源:common.php

示例15: array

 function upload_save($redirect = true)
 {
     global $my, $mainframe, $database, $option, $priTask, $subTask;
     global $WBG_CONFIG, $wbGalleryDB_cat, $wbGallery_common, $wbGallery_eng;
     // Prepare Runtime
     $tempDir = null;
     $known_images = array('image/pjpeg', 'image/jpeg', 'image/jpg', 'image/png', 'image/gif');
     $time = time();
     // Importing
     $importFolder = mosGetParam($_REQUEST, 'folder', '');
     if ($importFolder && !file_exists($importFolder)) {
         echo "<script> alert('Import Folder Does Not Exist'); document.location.href='index2.php?option=" . $option . "&task=image.upload'; </script>\n";
         exit;
     }
     // Default Values
     $defRow = new wbGalleryDB_img($database);
     $defRow->bind($_POST);
     // Debug
     echo "Image Processing Start: " . $time . '<br/>';
     // ==============================v========================================
     // Single File Upload
     if (!empty($_FILES['img']['tmp_name'])) {
         // Debug
         echo "Single File Detected <br/>";
         if (!in_array($_FILES['img']['type'], $known_images)) {
             echo "<script> alert('Image type: " . $_FILES['img']['type'] . " is an unknown type'); document.location.href='index2.php?option=" . $option . "&task=image.upload'; </script>\n";
             exit;
         }
         $wbGallery_eng->add($_FILES['img']['tmp_name'], $_FILES['img']['name'], $_FILES['img']['type'], $defRow);
         if ($redirect) {
             mosRedirect('index2.php?option=' . $option . '&task=image.upload', 'Image Saved');
         }
     }
     // ==============================v========================================
     // Zip File Upload
     if (!empty($_FILES['zip']['tmp_name'])) {
         //zip file upload
         // Debug
         echo "Compressed File Uploaded <br/>";
         // Create / Define Temporary Folder for Unzipped Files
         if (!mkdir($mainframe->getCfg('absolute_path') . '/media/' . $time)) {
             if (!mkdir('/tmp/' . $time)) {
                 echo "<script> alert('Unable to Create Temp Directory'); history.back(); </script>\n";
                 exit;
             } else {
                 $tempDir = '/tmp/' . $time;
             }
         } else {
             $tempDir = $mainframe->getCfg('absolute_path') . '/media/' . $time;
         }
         // Uncompress ZIP or TAR.GZ
         if (preg_match('/zip$/i', $_FILES['zip']['name'])) {
             // Load ZIP functions
             require_once $mainframe->getCfg('absolute_path') . '/administrator/includes/pcl/pclzip.lib.php';
             require_once $mainframe->getCfg('absolute_path') . '/administrator/includes/pcl/pclerror.lib.php';
             $zipfile = new PclZip($_FILES['zip']['tmp_name']);
             if (substr(PHP_OS, 0, 3) == 'WIN') {
                 define('OS_WINDOWS', 1);
             } else {
                 define('OS_WINDOWS', 0);
             }
             $ret = $zipfile->extract(PCLZIP_OPT_PATH, $tempDir);
             if ($ret == 0) {
                 $wbGallery_common->remove_dir($tempDir);
                 echo "<script> alert('ZIP Extraction Error: " . $zipfile->errorName(true) . "'); history.back(); </script>\n";
                 exit;
             }
         } elseif (preg_match('/tar.gz$/i', $_FILES['zip']['name'])) {
             // Load TAR functions
             require_once $mainframe->getCfg('absolute_path') . '/includes/Archive/Tar.php';
             $archive = new Archive_Tar($_FILES['zip']['tmp_name']);
             $archive->setErrorHandling(PEAR_ERROR_PRINT);
             if (!$archive->extractModify($tempDir, '')) {
                 $wbGallery_common->remove_dir($tempDir);
                 echo "<script> alert('TAR Extraction Error'); history.back(); </script>\n";
                 exit;
             }
         } else {
             // Unknown File...
             $wbGallery_common->remove_dir($tempDir);
             echo "<script> alert('Unknown File Format - Must be .ZIP or .TAR.GZ'); history.back(); </script>\n";
             exit;
         }
     }
     // Zip File Upload
     // ==============================v========================================
     // Process Files from Folder
     if ($tempDir || $importFolder) {
         $processDirs = array();
         $files_added = 0;
         $files_skipped = 0;
         if ($tempDir) {
             $processDirs[] = array('path' => $tempDir, 'remove' => 1);
         }
         if ($importFolder) {
             $processDirs[] = array('path' => $importFolder, 'remove' => 0);
         }
         if (count($processDirs)) {
             foreach ($processDirs as $procDir) {
                 // Read Files from Temp Folder
//.........这里部分代码省略.........
开发者ID:planetangel,项目名称:Planet-Angel-Website,代码行数:101,代码来源:image.php


注:本文中的Archive_Tar::setErrorHandling方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。