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


PHP Phar::isWritable方法代碼示例

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


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

示例1: compress

 /**
  * Compresses a file or combination of files in the archive
  * @param array|zibo\library\filesystem\File $source File objects of the files to compress
  * @param zibo\library\filesystem\File $prefix The path for the files in the archive
  * @return null
  * @throws zibo\library\archive\exception\ArchiveException when no source or an invalid source has been provided
  * @throws zibo\library\archive\exception\ArchiveException when the archive could not be created
  * @throws zibo\library\archive\exception\ArchiveException when the phars could not be written due to the configuration of PHP
  */
 public function compress($source, File $prefix = null)
 {
     if (!PhpPhar::canWrite()) {
         throw new ArchiveException('Phar library is not allowed to write phars. Check the PHP configuration for the phar.readonly setting.');
     }
     if (empty($source)) {
         throw new ArchiveException('No files provided');
     }
     $path = $this->file->getAbsolutePath();
     $parent = $this->file->getParent();
     $parent->create();
     if (!is_array($source)) {
         $source = array($source);
     }
     try {
         $phar = new PhpPhar($path);
     } catch (UnexpectedValueException $e) {
         throw new ArchiveException('Could not open ' . $path);
     }
     if (!$phar->isWritable()) {
         throw new ArchiveException('Archive ' . $this->file->getAbsolutePath() . ' is not writable');
     }
     $phar->startBuffering();
     foreach ($source as $file) {
         if (!$file instanceof File) {
             throw new ArchiveException('Invalid source provided: ' . $file);
         }
         $this->compressFile($phar, $file, $prefix);
     }
     $phar->stopBuffering();
 }
開發者ID:BGCX261,項目名稱:zibo-svn-to-git,代碼行數:40,代碼來源:Phar.php

示例2: __construct

 public function __construct($file, $flags = 0)
 {
     $this->name = $file;
     $this->file = __DIR__ . '/' . $file;
     $p = new Phar($this->file, Phar::CURRENT_AS_FILEINFO, $file);
     if (!$p->isWritable()) {
         throw new Exception("hoge");
     }
     $p->startBuffering();
     $this->driver = $p;
 }
開發者ID:sotarok,項目名稱:sandbox,代碼行數:11,代碼來源:pharstorage.php

示例3: Phar

var_dump($a['a.php']->isWritable());
var_dump($a['a.php']->isReadable());
ini_set('phar.readonly', 1);
clearstatcache();
var_dump($a['a.php']->isWritable());
var_dump($a['a.php']->isReadable());
ini_set('phar.readonly', 0);
clearstatcache();
var_dump($a['a.php']->isWritable());
var_dump($a['a.php']->isReadable());
?>
archive
<?php 
ini_set('phar.readonly', 0);
$p = new Phar('doesnotexisthere.phar');
var_dump($p->isWritable());
clearstatcache();
var_dump($a->isWritable());
var_dump($b->isWritable());
ini_set('phar.readonly', 1);
clearstatcache();
var_dump($a->isWritable());
var_dump($b->isWritable());
chmod($fname2, 00);
clearstatcache();
var_dump($a->isWritable());
var_dump($b->isWritable());
chmod($fname2, 0666);
?>
===DONE===
開發者ID:gleamingthecube,項目名稱:php,代碼行數:30,代碼來源:ext_phar_tests_phar_oo_iswriteable.php

示例4: Phar

     $file = $argv[2];
 } else {
     $file = $argv[2] . ".phar";
 }
 if (file_exists($file)) {
     try {
         $phar = new Phar($file, 0);
         if ($phar->hasMetadata()) {
             $metadata = metadataToString($phar->getMetadata());
         } else {
             $metadata = "No metadata found\n";
         }
         echo "Size: " . round(filesize($file) * 0.0009765625 * 0.0009765625, 2) . " MB (" . round(filesize($file) * 0.0009765625, 3) . " KB)\n";
         echo "Signature: " . $phar->getSignature()["hash"] . "\n";
         echo "Signature type: " . $phar->getSignature()["hash_type"] . "\n";
         echo "Writable: " . strbool($phar->isWritable()) . "\n";
         echo "Readable: " . strbool($phar->isReadable()) . "\n";
         echo "Metadata: " . $metadata;
         echo "Show stub (y, n)? ";
         $input = fopen("php://stdin", "r");
         $line = fgets($input);
         if (trim($line) == 'y') {
             echo $phar->getStub();
         }
         echo "\n";
     } catch (Exception $e) {
         echo "Invalid phar file\n";
     }
 } else {
     echo "File not found\n";
 }
開發者ID:PocketServers,項目名稱:ImagicalMine,代碼行數:31,代碼來源:phartools.php


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