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


PHP PhingFile::canRead方法代码示例

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


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

示例1: checkPreconditions

 /**
  * @throws BuildException
  */
 private function checkPreconditions()
 {
     if (is_null($this->destinationFile)) {
         throw new BuildException("destfile attribute must be set!", $this->getLocation());
     }
     if ($this->destinationFile->exists() && $this->destinationFile->isDirectory()) {
         throw new BuildException("destfile is a directory!", $this->getLocation());
     }
     if (!$this->destinationFile->canWrite()) {
         throw new BuildException("Can not write to the specified destfile!", $this->getLocation());
     }
     if (!is_null($this->baseDirectory)) {
         if (!$this->baseDirectory->exists()) {
             throw new BuildException("basedir '" . (string) $this->baseDirectory . "' does not exist!", $this->getLocation());
         }
     }
     if ($this->signatureAlgorithm == Phar::OPENSSL) {
         if (!extension_loaded('openssl')) {
             throw new BuildException("PHP OpenSSL extension is required for OpenSSL signing of Phars!", $this->getLocation());
         }
         if (is_null($this->key)) {
             throw new BuildException("key attribute must be set for OpenSSL signing!", $this->getLocation());
         }
         if (!$this->key->exists()) {
             throw new BuildException("key '" . (string) $this->key . "' does not exist!", $this->getLocation());
         }
         if (!$this->key->canRead()) {
             throw new BuildException("key '" . (string) $this->key . "' cannot be read!", $this->getLocation());
         }
     }
 }
开发者ID:namesco,项目名称:phing,代码行数:34,代码来源:PharPackageTask.php

示例2: parseFile

 /**
  * {@inheritDoc}
  */
 public function parseFile(PhingFile $file)
 {
     if (!$file->canRead()) {
         throw new IOException("Unable to read file: " . $file);
     }
     try {
         // We load the Yaml class without the use of namespaces to prevent
         // parse errors in PHP 5.2.
         $parserClass = '\\Symfony\\Component\\Yaml\\Parser';
         $parser = new $parserClass();
         // Cast properties to array in case parse() returns null.
         $properties = (array) $parser->parse(file_get_contents($file->getAbsolutePath()));
     } catch (Exception $e) {
         if (is_a($e, '\\Symfony\\Component\\Yaml\\Exception\\ParseException')) {
             throw new IOException("Unable to parse contents of " . $file . ": " . $e->getMessage());
         }
         throw $e;
     }
     $flattenedProperties = $this->flattenArray($properties);
     foreach ($flattenedProperties as $key => $flattenedProperty) {
         if (is_array($flattenedProperty)) {
             $flattenedProperties[$key] = implode(',', $flattenedProperty);
         }
     }
     return $flattenedProperties;
 }
开发者ID:Geeklog-Japan,项目名称:geeklog-japan,代码行数:29,代码来源:YamlFileParser.php

示例3: checkFileExists

 public function checkFileExists()
 {
     //Get the correct path to asset
     switch ($this->type) {
         case Asset::ASSET_TYPE_CSS:
             $this->assetFolder = $this->paths['css'];
             break;
         case Asset::ASSET_TYPE_JS:
             $this->assetFolder = $this->paths['js'];
             break;
         case Asset::ASSET_TYPE_IMAGE:
             $this->assetFolder = $this->paths['images'];
             break;
         default:
             $folder = '';
     }
     //Path to file
     $file = new PhingFile($this->assetsDir . '/' . $this->assetFolder . $this->file);
     //Check file exists
     if (!$file->exists()) {
         throw new BuildException("Unable to find asset file: " . $file->getAbsolutePath());
     }
     //Check we can read it
     if (!$file->canRead()) {
         throw IOException("Unable to read asset file: " . $file->getPath());
     }
     return $file;
 }
开发者ID:rcrowe,项目名称:phing-asset,代码行数:28,代码来源:Asset.php

示例4: load

 /**
  * Load properties from a file.
  *
  * @param PhingFile $file
  * @return void
  * @throws IOException - if unable to read file.
  */
 function load(PhingFile $file)
 {
     if ($file->canRead()) {
         $this->parse($file->getPath(), false);
     } else {
         throw new IOException("Can not read file " . $file->getPath());
     }
 }
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:15,代码来源:Properties.php

示例5: main

 /**
  *  Run the task.
  *
  * @throws BuildException  trouble, probably file IO
  */
 public function main()
 {
     if ($this->prefix != null && $this->regex != null) {
         throw new BuildException("Please specify either prefix or regex, but not both", $this->getLocation());
     }
     //copy the properties file
     $allProps = array();
     /* load properties from file if specified, otherwise use Phing's properties */
     if ($this->inFile == null) {
         // add phing properties
         $allProps = $this->getProject()->getProperties();
     } elseif ($this->inFile != null) {
         if ($this->inFile->exists() && $this->inFile->isDirectory()) {
             $message = "srcfile is a directory!";
             $this->failOnErrorAction(null, $message, Project::MSG_ERR);
             return;
         }
         if ($this->inFile->exists() && !$this->inFile->canRead()) {
             $message = "Can not read from the specified srcfile!";
             $this->failOnErrorAction(null, $message, Project::MSG_ERR);
             return;
         }
         try {
             $props = new Properties();
             $props->load(new PhingFile($this->inFile));
             $allProps = $props->getProperties();
         } catch (IOException $ioe) {
             $message = "Could not read file " . $this->inFile->getAbsolutePath();
             $this->failOnErrorAction($ioe, $message, Project::MSG_WARN);
             return;
         }
     }
     $os = null;
     try {
         if ($this->destfile == null) {
             $os = Phing::getOutputStream();
             $this->saveProperties($allProps, $os);
             $this->log($os, Project::MSG_INFO);
         } else {
             if ($this->destfile->exists() && $this->destfile->isDirectory()) {
                 $message = "destfile is a directory!";
                 $this->failOnErrorAction(null, $message, Project::MSG_ERR);
                 return;
             }
             if ($this->destfile->exists() && !$this->destfile->canWrite()) {
                 $message = "Can not write to the specified destfile!";
                 $this->failOnErrorAction(null, $message, Project::MSG_ERR);
                 return;
             }
             $os = new FileOutputStream($this->destfile);
             $this->saveProperties($allProps, $os);
         }
     } catch (IOException $ioe) {
         $this->failOnErrorAction($ioe);
     }
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:61,代码来源:EchoProperties.php

示例6: yuiAddFile

 private function yuiAddFile($file, $is_css = FALSE)
 {
     if (!$is_css) {
         $folder = '/js/';
     } else {
         $folder = '/css/';
     }
     $add = new PhingFile($this->assetDir . $folder . $file->file);
     if ($add->exists() && $add->canRead()) {
         $this->yui->addFile($add->getAbsolutePath());
     } else {
         throw new BuildException("Unable to read asset file: " . $add->getPath(), $this->location);
     }
 }
开发者ID:rcrowe,项目名称:phing-asset,代码行数:14,代码来源:Compress.php

示例7: isSelected

 /**
  * Tests whether a name should be selected.
  *
  * @param  string  $name The filename to check for selecting.
  * @param  string  $file The full file path.
  * @return boolean False when the selectors says that the file
  *                      should not be selected, True otherwise.
  */
 protected function isSelected($name, $file)
 {
     if ($this->selectors !== null) {
         $basedir = new PhingFile($this->basedir);
         $file = new PhingFile($file);
         if (!$file->canRead()) {
             return false;
         }
         foreach ($this->selectors as $selector) {
             if (!$selector->isSelected($basedir, $name, $file)) {
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:Ingewikkeld,项目名称:phing,代码行数:24,代码来源:DirectoryScanner.php

示例8: _verifyManifest

    /**
     * @return void
     */
    protected function _verifyManifest()
    {
        if (!$this->_file->isFile() || !$this->_file->canRead()) {
            throw new BuildException(
                'Failed reading from manifest file',
                $this->location
            );
        }

        $manifest = array ();
        $fp = fopen($this->_file, 'r');
        while (true == ($line = trim(fgets($fp)))) {
            list ($path, $hash) = explode("\t", $line);
            $manifest[$path] = $hash;
        }
        fclose($fp);

        $verified = true;

        // Check for files present which are not in the manifest
        $filesNotInManifest = array_keys(array_diff_key($manifest, $this->_hashes));
        if (!empty ($filesNotInManifest)) {
            $verified = false;
            $this->log(
                'There are ' . count($filesNotInManifest) . ' files present which are not listed in the manifest',
                PROJECT::MSG_WARN
            );
            foreach ($filesNotInManifest as $path) {
                $this->log(
                    'Extra file: ' . $path,
                    PROJECT::MSG_WARN
                );
            }
            unset ($path);
        }
        unset ($filesNotInManifest);

        // Check for files listed in the manifest which are not present
        $filesNotPresent = array_keys(array_diff_key($this->_hashes, $manifest));
        if (!empty ($filesNotPresent)) {
            $verified = false;
            $this->log(
                'There are ' . count($filesNotPresent) . ' files listed in the manifest which are not present',
                PROJECT::MSG_WARN
            );
            foreach ($filesNotPresent as $path) {
                $this->log(
                    'Missing file: ' . $path,
                    PROJECT::MSG_WARN
                );
            }
            unset ($path);
        }
        unset ($filesNotPresent);

        // Compare manifest hashes with the computed hashes
        $filesPresent = array_keys(array_intersect_key($manifest, $this->_hashes));
        foreach ($filesPresent as $path) {
            if ($manifest[$path] != $this->_hashes[$path]) {
                $verified = false;
                $this->log(
                    'Hashes do not match: ' . $path,
                    PROJECT::MSG_WARN
                );
            }
        }
        unset ($filesPresent);

        if (!$verified) {
            throw new BuildException(
                'Manifest verification failed'
            );
        }

        $this->log('Manifest verification successful');
    }
开发者ID:rchouinard,项目名称:phing-tasks,代码行数:79,代码来源:ManifestFileTask.php

示例9: contentEquals

 /**
  * @return boolean Whether contents of two files is the same.
  */
 public function contentEquals(PhingFile $file1, PhingFile $file2)
 {
     if (!($file1->exists() || $file2->exists())) {
         return false;
     }
     if (!($file1->canRead() || $file2->canRead())) {
         return false;
     }
     $c1 = file_get_contents($file1->getAbsolutePath());
     $c2 = file_get_contents($file2->getAbsolutePath());
     return trim($c1) == trim($c2);
 }
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:15,代码来源:FileUtils.php

示例10: isSelected

 /**
  * {@inheritdoc}
  *
  * @param PhingFile $basedir
  * @param string $filename
  * @param PhingFile $file
  *
  * @return bool
  */
 public function isSelected(PhingFile $basedir, $filename, PhingFile $file)
 {
     return $file !== null && $file->canRead();
 }
开发者ID:tammyd,项目名称:phing,代码行数:13,代码来源:ReadableSelector.php


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