當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PEAR_PackageFile_v2::setFileAttribute方法代碼示例

本文整理匯總了PHP中PEAR_PackageFile_v2::setFileAttribute方法的典型用法代碼示例。如果您正苦於以下問題:PHP PEAR_PackageFile_v2::setFileAttribute方法的具體用法?PHP PEAR_PackageFile_v2::setFileAttribute怎麽用?PHP PEAR_PackageFile_v2::setFileAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PEAR_PackageFile_v2的用法示例。


在下文中一共展示了PEAR_PackageFile_v2::setFileAttribute方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: basename


//.........這裏部分代碼省略.........
             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}");
             } else {
                 $tfile = $packageDir . DIRECTORY_SEPARATOR . $fname;
                 unset($orig['attribs']);
                 if (count($orig)) {
                     // file with tasks
                     // run any package-time tasks
                     if (function_exists('file_get_contents')) {
                         $contents = file_get_contents($file);
                     } else {
                         $fp = fopen($file, "r");
                         $contents = @fread($fp, filesize($file));
                         fclose($fp);
                     }
                     foreach ($orig as $tag => $raw) {
                         $tag = str_replace($this->_packagefile->getTasksNs() . ':', '', $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);
                 }
                 $filelist[$i++] = $tfile;
                 $this->_packagefile->setFileAttribute($fname, 'md5sum', md5_file($tfile), $i - 1);
                 $packager->log(2, "Adding file {$fname}");
             }
         }
     }
     // }}}
     if ($pf1 !== null) {
         $name = 'package2.xml';
     } else {
         $name = '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:prometheus-ev,項目名稱:promdilps,代碼行數:101,代碼來源:v2.php


注:本文中的PEAR_PackageFile_v2::setFileAttribute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。