当前位置: 首页>>代码示例>>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;未经允许,请勿转载。