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


PHP PhingFile::exists方法代码示例

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


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

示例1: build

 /**
  * Uses a builder class to create the output class.
  * This method assumes that the DataModelBuilder class has been initialized with the build properties.
  *
  * @param OMBuilder $builder
  * @param boolean   $overwrite Whether to overwrite existing files with te new ones (default is YES).
  *
  * @todo       -cPropelOMTask Consider refactoring build() method into AbstractPropelDataModelTask (would need to be more generic).
  * @return int
  */
 protected function build(OMBuilder $builder, $overwrite = true)
 {
     $path = $builder->getClassFilePath();
     $this->ensureDirExists(dirname($path));
     $_f = new PhingFile($this->getOutputDirectory(), $path);
     // skip files already created once
     if ($_f->exists() && !$overwrite) {
         $this->log("\t-> (exists) " . $builder->getClassFilePath(), Project::MSG_VERBOSE);
         return 0;
     }
     $script = $builder->build();
     foreach ($builder->getWarnings() as $warning) {
         $this->log($warning, Project::MSG_WARN);
     }
     // skip unchanged files
     if ($_f->exists() && $script == $_f->contents()) {
         $this->log("\t-> (unchanged) " . $builder->getClassFilePath(), Project::MSG_VERBOSE);
         return 0;
     }
     // write / overwrite new / changed files
     $action = $_f->exists() ? 'Updating' : 'Creating';
     $this->log(sprintf("\t-> %s %s (table: %s, builder: %s)", $action, $builder->getClassFilePath(), $builder->getTable()->getName(), get_class($builder)));
     file_put_contents($_f->getAbsolutePath(), $script);
     return 1;
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:35,代码来源:PropelOMTask.php

示例2: 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

示例3: main

 public function main()
 {
     if (empty($this->filesets)) {
         throw new BuildException("You must specify a file or fileset(s).");
     }
     if (empty($this->_compilePath)) {
         throw new BuildException("You must specify location for compiled templates.");
     }
     date_default_timezone_set("America/New_York");
     $project = $this->getProject();
     $this->_count = $this->_total = 0;
     $smartyCompilePath = new PhingFile($this->_compilePath);
     if (!$smartyCompilePath->exists()) {
         $this->log("Compile directory does not exist, creating: " . $smartyCompilePath->getPath(), Project::MSG_VERBOSE);
         if (!$smartyCompilePath->mkdirs()) {
             throw new BuildException("Error creating compile path for Smarty in " . $this->_compilePath);
         }
     }
     $this->_smarty = new Smarty();
     $this->_smarty->use_sub_dirs = true;
     $this->_smarty->compile_dir = $smartyCompilePath;
     $this->_smarty->plugins_dir[] = $this->_pluginsPath;
     $this->_smarty->force_compile = $this->_forceCompile;
     // process filesets
     foreach ($this->filesets as $fs) {
         $ds = $fs->getDirectoryScanner($project);
         $fromDir = $fs->getDir($project);
         $srcFiles = $ds->getIncludedFiles();
         $this->_compile($fromDir, $srcFiles);
     }
     $this->log("Compiled " . $this->_count . " out of " . $this->_total . " Smarty templates");
 }
开发者ID:hellogerard,项目名称:phing-things,代码行数:32,代码来源:SmartyCompileTask.php

示例4: 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

示例5: selectionTest

 /**
  * This test is our selection test that compared the file with the destfile.
  *
  * @param PhingFile $srcfile the source file
  * @param PhingFile $destfile the destination file
  * @return bool true if the files are different
  *
  * @throws BuildException
  */
 protected function selectionTest(PhingFile $srcfile, PhingFile $destfile)
 {
     try {
         // if either of them is missing, they are different
         if ($srcfile->exists() !== $destfile->exists()) {
             return true;
         }
         if ($srcfile->length() !== $destfile->length()) {
             // different size => different files
             return true;
         }
         if (!$this->ignoreFileTimes) {
             // different dates => different files
             if ($destfile->lastModified() !== $srcfile->lastModified()) {
                 return true;
             }
         }
         if (!$this->ignoreContents) {
             //here do a bulk comparison
             $fu = new FileUtils();
             return !$fu->contentEquals($srcfile, $destfile);
         }
     } catch (IOException $e) {
         throw new BuildException("while comparing {$srcfile} and {$destfile}", $e);
     }
     return false;
 }
开发者ID:Geeklog-Japan,项目名称:geeklog-japan,代码行数:36,代码来源:DifferentSelector.php

示例6: setOutputDirectory

 /**
  * Set the sqldbmap.
  * @param      PhingFile $sqldbmap The db map.
  */
 public function setOutputDirectory(PhingFile $out)
 {
     if (!$out->exists()) {
         $out->mkdirs();
     }
     $this->outDir = $out;
 }
开发者ID:JimmyVB,项目名称:Symfony-v1.2,代码行数:11,代码来源:PropelGraphvizTask.php

示例7: createDirectories

 private function createDirectories($path)
 {
     $f = new PhingFile($path);
     if (!$f->exists()) {
         $f->mkdirs();
     }
 }
开发者ID:sensorsix,项目名称:app,代码行数:7,代码来源:ExtendedFileStream.php

示例8: setDir

 public function setDir(PhingFile $dir)
 {
     if (!$dir->exists()) {
         throw new BuildException("Can not find asset directory: " . $dir->getAbsolutePath(), $this->location);
     }
     $this->assetDir = $dir->getAbsolutePath();
 }
开发者ID:rcrowe,项目名称:phing-asset,代码行数:7,代码来源:Assets.php

示例9: main

 /**
  * do the work
  * @throws BuildException
  */
 public function main()
 {
     if ($this->zipFile === null) {
         throw new BuildException("zipFile attribute must be set!", $this->getLocation());
     }
     if ($this->zipFile->exists() && $this->zipFile->isDirectory()) {
         throw new BuildException("zipFile is a directory!", $this->getLocation());
     }
     if ($this->zipFile->exists() && !$this->zipFile->canWrite()) {
         throw new BuildException("Can not write to the specified zipFile!", $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 (empty($this->filesets)) {
             throw new BuildException("You must supply some nested filesets.", $this->getLocation());
         }
         $this->log("Building ZIP: " . $this->zipFile->__toString(), Project::MSG_INFO);
         $zip = new PclZip($this->zipFile->getAbsolutePath());
         if ($zip->errorCode() != 1) {
             throw new Exception("PclZip::open() failed: " . $zip->errorInfo());
         }
         foreach ($this->filesets as $fs) {
             $files = $fs->getFiles($this->project, $this->includeEmpty);
             $fsBasedir = null != $this->baseDir ? $this->baseDir : $fs->getDir($this->project);
             $filesToZip = array();
             for ($i = 0, $fcount = count($files); $i < $fcount; $i++) {
                 $f = new PhingFile($fsBasedir, $files[$i]);
                 //$filesToZip[] = realpath($f->getPath());
                 $fileAbsolutePath = $f->getPath();
                 $fileDir = rtrim(dirname($fileAbsolutePath), '/\\');
                 $fileBase = basename($fileAbsolutePath);
                 if (substr($fileDir, -4) == '.svn') {
                     continue;
                 }
                 if ($fileBase == '.svn') {
                     continue;
                 }
                 if (substr(rtrim($fileAbsolutePath, '/\\'), -4) == '.svn') {
                     continue;
                 }
                 //echo "\t\t$fileAbsolutePath\n";
                 $filesToZip[] = $f->getPath();
             }
             /*
             $zip->add($filesToZip,
             	PCLZIP_OPT_ADD_PATH, is_null($this->prefix) ? '' : $this->prefix ,
             	PCLZIP_OPT_REMOVE_PATH, realpath($fsBasedir->getPath()) );
             */
             $zip->add($filesToZip, PCLZIP_OPT_ADD_PATH, is_null($this->prefix) ? '' : $this->prefix, PCLZIP_OPT_REMOVE_PATH, $fsBasedir->getPath());
         }
     } catch (IOException $ioe) {
         $msg = "Problem creating ZIP: " . $ioe->getMessage();
         $this->filesets = $savedFileSets;
         throw new BuildException($msg, $ioe, $this->getLocation());
     }
     $this->filesets = $savedFileSets;
 }
开发者ID:prox91,项目名称:joomla-dev,代码行数:63,代码来源:ZipmeTask.php

示例10: 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

示例11: doWork

 /**
  * Copied from 'CopyTask.php'
  */
 protected function doWork()
 {
     // These "slots" allow filters to retrieve information about the currently-being-process files
     $fromSlot = $this->getRegisterSlot("currentFromFile");
     $fromBasenameSlot = $this->getRegisterSlot("currentFromFile.basename");
     $toSlot = $this->getRegisterSlot("currentToFile");
     $toBasenameSlot = $this->getRegisterSlot("currentToFile.basename");
     $mapSize = count($this->fileCopyMap);
     $total = $mapSize;
     if ($mapSize > 0) {
         $this->log("Minifying " . $mapSize . " file" . ($mapSize === 1 ? '' : 's') . " to " . $this->destDir->getAbsolutePath());
         // walks the map and actually copies the files
         $count = 0;
         foreach ($this->fileCopyMap as $from => $to) {
             if ($from === $to) {
                 $this->log("Skipping self-copy of " . $from, $this->verbosity);
                 $total--;
                 continue;
             }
             $this->log("From " . $from . " to " . $to, $this->verbosity);
             try {
                 // try to copy file
                 $fromFile = new PhingFile($from);
                 $toFile = new PhingFile($to);
                 $fromSlot->setValue($fromFile->getPath());
                 $fromBasenameSlot->setValue($fromFile->getName());
                 $toSlot->setValue($toFile->getPath());
                 $toBasenameSlot->setValue($toFile->getName());
                 $this->fileUtils->copyFile($fromFile, $toFile, $this->overwrite, $this->preserveLMT, $this->filterChains, $this->getProject());
                 // perform ''minification'' once all other things are done on it.
                 $this->minify($toFile);
                 $count++;
             } catch (IOException $ioe) {
                 $this->log("Failed to minify " . $from . " to " . $to . ": " . $ioe->getMessage(), Project::MSG_ERR);
             }
         }
     }
     // handle empty dirs if appropriate
     if ($this->includeEmpty) {
         $destdirs = array_values($this->dirCopyMap);
         $count = 0;
         foreach ($destdirs as $destdir) {
             $d = new PhingFile((string) $destdir);
             if (!$d->exists()) {
                 if (!$d->mkdirs()) {
                     $this->log("Unable to create directory " . $d->__toString(), Project::MSG_ERR);
                 } else {
                     $count++;
                 }
             }
         }
         if ($count > 0) {
             $this->log("Copied " . $count . " empty director" . ($count == 1 ? "y" : "ies") . " to " . $this->destDir->getAbsolutePath());
         }
     }
 }
开发者ID:jldupont,项目名称:jldupont.com,代码行数:59,代码来源:JsMinTask.php

示例12: main

 /**
  * Do the work
  *
  * @throws BuildException
  */
 public function main()
 {
     if ($this->zipFile === null) {
         throw new BuildException("zipFile attribute must be set!", $this->getLocation());
     }
     if ($this->zipFile->exists() && $this->zipFile->isDirectory()) {
         throw new BuildException("zipFile is a directory!", $this->getLocation());
     }
     if ($this->zipFile->exists() && !$this->zipFile->canWrite()) {
         throw new BuildException("Can not write to the specified zipFile!", $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 (empty($this->filesets)) {
             throw new BuildException("You must supply some nested filesets.", $this->getLocation());
         }
         $this->log("Building ZIP: " . $this->zipFile->__toString(), Project::MSG_INFO);
         $zip = new PclZip($this->zipFile->getAbsolutePath());
         if ($zip->errorCode() != 1) {
             throw new Exception("PclZip::open() failed: " . $zip->errorInfo());
         }
         foreach ($this->filesets as $fs) {
             $files = $fs->getFiles($this->project, $this->includeEmpty);
             $fsBasedir = $this->baseDir != null ? $this->baseDir : $fs->getDir($this->project);
             $filesToZip = array();
             foreach ($files as $file) {
                 $f = new PhingFile($fsBasedir, $file);
                 $fileAbsolutePath = $f->getPath();
                 $fileDir = rtrim(dirname($fileAbsolutePath), '/\\');
                 $fileBase = basename($fileAbsolutePath);
                 // Only use lowercase for $disallowedBases because we'll convert $fileBase to lowercase
                 $disallowedBases = array('.ds_store', '.svn', '.gitignore', 'thumbs.db');
                 $fileBaseLower = strtolower($fileBase);
                 if (in_array($fileBaseLower, $disallowedBases)) {
                     continue;
                 }
                 if (substr($fileDir, -4) == '.svn') {
                     continue;
                 }
                 if (substr(rtrim($fileAbsolutePath, '/\\'), -4) == '.svn') {
                     continue;
                 }
                 $filesToZip[] = $fileAbsolutePath;
             }
             $zip->add($filesToZip, PCLZIP_OPT_ADD_PATH, is_null($this->prefix) ? '' : $this->prefix, PCLZIP_OPT_REMOVE_PATH, $fsBasedir->getPath());
         }
     } catch (IOException $ioe) {
         $msg = "Problem creating ZIP: " . $ioe->getMessage();
         $this->filesets = $savedFileSets;
         throw new BuildException($msg, $ioe, $this->getLocation());
     }
     $this->filesets = $savedFileSets;
 }
开发者ID:Coyotejld,项目名称:buildfiles,代码行数:60,代码来源:ZipmeTask.php

示例13: main

 /**
  * do the work
  * @throws BuildException
  */
 public function main()
 {
     if (!extension_loaded('zip')) {
         throw new BuildException("Zip extension is required");
     }
     if ($this->zipFile === null) {
         throw new BuildException("zipfile attribute must be set!", $this->getLocation());
     }
     if ($this->zipFile->exists() && $this->zipFile->isDirectory()) {
         throw new BuildException("zipfile is a directory!", $this->getLocation());
     }
     if ($this->zipFile->exists() && !$this->zipFile->canWrite()) {
         throw new BuildException("Can not write to the specified zipfile!", $this->getLocation());
     }
     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)) {
                 // add the main fileset to the list of filesets to process.
                 $mainFileSet = new ZipFileSet($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 zip is out of date with respect to each
         // fileset
         if ($this->areFilesetsUpToDate()) {
             $this->log("Nothing to do: " . $this->zipFile->__toString() . " is up to date.", Project::MSG_INFO);
             return;
         }
         $this->log("Building zip: " . $this->zipFile->__toString(), Project::MSG_INFO);
         $zip = new ZipArchive();
         $res = $zip->open($this->zipFile->getAbsolutePath(), ZIPARCHIVE::CREATE);
         if ($res !== true) {
             throw new Exception("ZipArchive::open() failed with code " . $res);
         }
         if ($this->comment !== '') {
             $isCommented = $zip->setArchiveComment($this->comment);
             if ($isCommented === false) {
                 $this->log("Could not add a comment for the Archive.", Project::MSG_INFO);
             }
         }
         $this->addFilesetsToArchive($zip);
         $zip->close();
     } catch (IOException $ioe) {
         $msg = "Problem creating ZIP: " . $ioe->getMessage();
         throw new BuildException($msg, $ioe, $this->getLocation());
     }
 }
开发者ID:alangalipaud,项目名称:ProjetQCM,代码行数:58,代码来源:ZipTask.php

示例14: initPhar

 /**
  * @return Phar
  */
 private function initPhar()
 {
     /**
      * Delete old package, if exists.
      */
     if ($this->destinationFile->exists()) {
         $this->destinationFile->delete();
     }
     $phar = $this->buildPhar();
     return $phar;
 }
开发者ID:navarr,项目名称:n98-magerun,代码行数:14,代码来源:PatchedPharPackageTask.php

示例15: output

 private function output($is_css, $data, $js)
 {
     if (!$is_css) {
         $folder = '/js/';
     } else {
         $folder = '/css/';
     }
     //Build path to output file
     $out = new PhingFile($this->assetDir . $folder . $js->file);
     //Check whether to overwrite files
     if ($out->exists() && !$js->overwrite) {
         throw new BuildException("Trying to write to " . $js->file . " but the overwrite flag has not been set to TRUE", $this->location);
     } else {
         if ($out->exists()) {
             $out->delete();
         }
     }
     //Write compressed JS to file
     file_put_contents($out->getAbsolutePath(), $data);
 }
开发者ID:rcrowe,项目名称:phing-asset,代码行数:20,代码来源:Compress.php


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