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


PHP PhingFile::delete方法代码示例

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


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

示例1: copyFile

 /**
  * Copies a file using filter chains.
  * 
  * @param PhingFile $sourceFile
  * @param PhingFile $destFile
  * @param boolean $overwrite
  * @param boolean $preserveLastModified
  * @param array $filterChains 
  * @param Project $project
  * @return void
  */
 function copyFile(PhingFile $sourceFile, PhingFile $destFile, $overwrite = false, $preserveLastModified = true, &$filterChains = null, Project $project)
 {
     if ($overwrite || !$destFile->exists() || $destFile->lastModified() < $sourceFile->lastModified()) {
         if ($destFile->exists() && $destFile->isFile()) {
             $destFile->delete();
         }
         // ensure that parent dir of dest file exists!
         $parent = $destFile->getParentFile();
         if ($parent !== null && !$parent->exists()) {
             $parent->mkdirs();
         }
         if (is_array($filterChains) && !empty($filterChains)) {
             $in = self::getChainedReader(new BufferedReader(new FileReader($sourceFile)), $filterChains, $project);
             $out = new BufferedWriter(new FileWriter($destFile));
             // New read() methods returns a big buffer.
             while (-1 !== ($buffer = $in->read())) {
                 // -1 indicates EOF
                 $out->write($buffer);
             }
             if ($in !== null) {
                 $in->close();
             }
             if ($out !== null) {
                 $out->close();
             }
         } else {
             // simple copy (no filtering)
             $sourceFile->copyTo($destFile);
         }
         if ($preserveLastModified) {
             $destFile->setLastModified($sourceFile->lastModified());
         }
     }
 }
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:45,代码来源:FileUtils.php

示例2: main

 /**
  * @throws BuildException
  */
 public function main()
 {
     $this->checkPreconditions();
     try {
         $this->log('Building package: ' . $this->destinationFile->__toString(), Project::MSG_INFO);
         /*
          * Delete old package, if exists.
          */
         if ($this->destinationFile->exists()) {
             /*
              * TODO Check operation for errors...
              */
             $this->destinationFile->delete();
         }
         $phar = $this->buildPhar();
         $phar->startBuffering();
         $baseDirectory = realpath($this->baseDirectory->getPath());
         foreach ($this->filesets as $fileset) {
             foreach ($fileset as $realFileName) {
                 /*
                  * Calculate local file name.
                  */
                 $localFileName = $realFileName;
                 if (0 === strpos($realFileName, $baseDirectory)) {
                     $localFileName = substr($realFileName, strlen($baseDirectory));
                 }
                 $this->log('Adding ' . $realFileName . ' as ' . $localFileName . ' to package', Project::MSG_VERBOSE);
                 $phar->addFile($realFileName, $localFileName);
             }
         }
         $phar->stopBuffering();
     } catch (Exception $e) {
         throw new BuildException('Problem creating package: ' . $e->getMessage(), $e, $this->getLocation());
     }
 }
开发者ID:kulobone,项目名称:mongodb,代码行数:38,代码来源:PharPackageTask.php

示例3: main

 /**
  * @throws BuildException
  */
 public function main()
 {
     $this->checkPreconditions();
     try {
         $this->log('Building package: ' . $this->destinationFile->__toString(), Project::MSG_INFO);
         /*
          * Delete old package, if exists.
          */
         if ($this->destinationFile->exists()) {
             /*
              * TODO Check operation for errors...
              */
             $this->destinationFile->delete();
         }
         $phar = $this->buildPhar();
         $phar->startBuffering();
         $baseDirectory = realpath($this->baseDirectory->getPath());
         foreach ($this->filesets as $fileset) {
             $this->log('Adding specified files in ' . $fileset->getDir($this->project) . ' to package', Project::MSG_VERBOSE);
             $phar->buildFromIterator($fileset, $baseDirectory);
         }
         $phar->stopBuffering();
         /*
          * File compression, if needed.
          */
         if (Phar::NONE != $this->compression) {
             $phar->compressFiles($this->compression);
         }
     } catch (Exception $e) {
         throw new BuildException('Problem creating package: ' . $e->getMessage(), $e, $this->getLocation());
     }
 }
开发者ID:altesien,项目名称:FinalProject,代码行数:35,代码来源:PharPackageTask.php

示例4: main

 /**
  * @throws BuildException
  */
 public function main()
 {
     $this->checkPreconditions();
     try {
         $this->log('Building archive: ' . $this->destinationFile->__toString(), Project::MSG_INFO);
         /**
          * Delete old archive, if exists.
          */
         if ($this->destinationFile->exists()) {
             $isDeleted = $this->destinationFile->delete();
             if (!$isDeleted) {
                 $this->log("Could not delete destination file {$this->destinationFile}", Project::MSG_WARN);
             }
         }
         $pharData = new PharData($this->baseDirectory->getPath() . '/' . $this->destinationFile->getName());
         foreach ($this->filesets as $fileset) {
             $this->log('Adding specified files in ' . $fileset->getDir($this->project) . ' to archive', Project::MSG_VERBOSE);
             $pharData->buildFromIterator($fileset->getIterator(), $fileset->getDir($this->project));
         }
         if ($this->compression !== PHAR::NONE && $pharData->canCompress($this->compression)) {
             try {
                 $pharData->compress($this->compression);
             } catch (UnexpectedValueException $uve) {
                 $pharData->compressFiles($this->compression);
             }
             unset($pharData);
         }
     } catch (Exception $e) {
         throw new BuildException('Problem creating archive: ' . $e->getMessage(), $e, $this->getLocation());
     }
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:34,代码来源:PharDataTask.php

示例5: testCorrectModeSet

 public function testCorrectModeSet()
 {
     $this->executeTarget("test");
     $dir = new PhingFile(PHING_TEST_BASE . "/etc/regression/745/testdir");
     $mode = $dir->getMode() & 511;
     $this->assertEquals($mode, 511);
     $dir->delete(true);
 }
开发者ID:laiello,项目名称:lion-framework,代码行数:8,代码来源:MkdirTaskModeTest.php

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

示例7: main

 /**
  * @throws BuildException
  */
 public function main()
 {
     $this->checkPreconditions();
     try {
         $this->log('Building package: ' . $this->destinationFile->__toString(), Project::MSG_INFO);
         /**
          * Delete old package, if exists.
          */
         if ($this->destinationFile->exists()) {
             /**
              * TODO Check operation for errors...
              */
             $this->destinationFile->delete();
         }
         $phar = $this->buildPhar();
         $phar->startBuffering();
         $baseDirectory = realpath($this->baseDirectory->getPath());
         foreach ($this->filesets as $fileset) {
             $this->log('Adding specified files in ' . $fileset->getDir($this->project) . ' to package', Project::MSG_VERBOSE);
             $phar->buildFromIterator($fileset, $baseDirectory);
         }
         $phar->stopBuffering();
         /**
          * File compression, if needed.
          */
         if (Phar::NONE != $this->compression) {
             $phar->compressFiles($this->compression);
         }
         if ($this->signatureAlgorithm == Phar::OPENSSL) {
             // Load up the contents of the key
             $keyContents = file_get_contents($this->key);
             // Attempt to load the given key as a PKCS#12 Cert Store first.
             if (openssl_pkcs12_read($keyContents, $certs, $this->keyPassword)) {
                 $private = openssl_pkey_get_private($certs['pkey']);
             } else {
                 // Fall back to a regular PEM-encoded private key.
                 // Setup an OpenSSL resource using the private key
                 // and tell the Phar to sign it using that key.
                 $private = openssl_pkey_get_private($keyContents, $this->keyPassword);
             }
             openssl_pkey_export($private, $pkey);
             $phar->setSignatureAlgorithm(Phar::OPENSSL, $pkey);
             // Get the details so we can get the public key and write that out
             // alongside the phar.
             $details = openssl_pkey_get_details($private);
             file_put_contents($this->destinationFile . '.pubkey', $details['key']);
         } else {
             $phar->setSignatureAlgorithm($this->signatureAlgorithm);
         }
     } catch (Exception $e) {
         throw new BuildException('Problem creating package: ' . $e->getMessage(), $e, $this->getLocation());
     }
 }
开发者ID:tammyd,项目名称:phing,代码行数:56,代码来源:PharPackageTask.php

示例8: copyFile

 /**
  * Copies a file using filter chains.
  *
  * @param  PhingFile $sourceFile
  * @param  PhingFile $destFile
  * @param  boolean   $overwrite
  * @param  boolean   $preserveLastModified
  * @param  array     $filterChains
  * @param  Project   $project
  * @param  integer   $mode
  * @param bool       $preservePermissions
  *
  * @throws Exception
  * @throws IOException
  * @return void
  */
 public function copyFile(PhingFile $sourceFile, PhingFile $destFile, $overwrite = false, $preserveLastModified = true, &$filterChains = null, Project $project, $mode = 0755, $preservePermissions = true)
 {
     if ($overwrite || !$destFile->exists() || $destFile->lastModified() < $sourceFile->lastModified()) {
         if ($destFile->exists() && $destFile->isFile()) {
             $destFile->delete();
         }
         // ensure that parent dir of dest file exists!
         $parent = $destFile->getParentFile();
         if ($parent !== null && !$parent->exists()) {
             // Setting source directory permissions to target
             // (On permissions preservation, the target directory permissions
             // will be inherited from the source directory, otherwise the 'mode'
             // will be used)
             $dirMode = $preservePermissions ? $sourceFile->getParentFile()->getMode() : $mode;
             $parent->mkdirs($dirMode);
         }
         if (is_array($filterChains) && !empty($filterChains)) {
             $in = self::getChainedReader(new BufferedReader(new FileReader($sourceFile)), $filterChains, $project);
             $out = new BufferedWriter(new FileWriter($destFile));
             // New read() methods returns a big buffer.
             while (-1 !== ($buffer = $in->read())) {
                 // -1 indicates EOF
                 $out->write($buffer);
             }
             if ($in !== null) {
                 $in->close();
             }
             if ($out !== null) {
                 $out->close();
             }
             // Set/Copy the permissions on the target
             if ($preservePermissions === true) {
                 $destFile->setMode($sourceFile->getMode());
             }
         } else {
             // simple copy (no filtering)
             $sourceFile->copyTo($destFile);
             // By default, PHP::Copy also copies the file permissions. Therefore,
             // re-setting the mode with the "user file-creation mask" information.
             if ($preservePermissions === false) {
                 $destFile->setMode(FileUtils::getDefaultFileCreationMask(false, true));
             }
         }
         if ($preserveLastModified && !$destFile->isLink()) {
             $destFile->setLastModified($sourceFile->lastModified());
         }
     }
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:64,代码来源:FileUtils.php

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

示例10: removeFiles

 /**
  * remove an array of files in a directory, and a list of subdirectories
  * which will only be deleted if 'includeEmpty' is true
  * @param PhingFile $d directory to work from
  * @param array &$files array of files to delete; can be of zero length
  * @param array &$dirs array of directories to delete; can of zero length
  */
 private function removeFiles(PhingFile $d, &$files, &$dirs)
 {
     if (count($files) > 0) {
         $this->log("Deleting " . count($files) . " files from " . $d->__toString());
         for ($j = 0, $_j = count($files); $j < $_j; $j++) {
             $f = new PhingFile($d, $files[$j]);
             $this->log("Deleting " . $f->getAbsolutePath(), $this->verbosity);
             try {
                 $f->delete();
             } catch (Exception $e) {
                 $message = "Unable to delete file " . $f->__toString() . ": " . $e->getMessage();
                 if ($this->failonerror) {
                     throw new BuildException($message);
                 } else {
                     $this->log($message, $this->quiet ? Project::MSG_VERBOSE : Project::MSG_WARN);
                 }
             }
         }
     }
     if (count($dirs) > 0 && $this->includeEmpty) {
         $dirCount = 0;
         for ($j = count($dirs) - 1; $j >= 0; --$j) {
             $dir = new PhingFile($d, $dirs[$j]);
             $dirFiles = $dir->listDir();
             if ($dirFiles === null || count($dirFiles) === 0) {
                 $this->log("Deleting " . $dir->__toString(), $this->verbosity);
                 try {
                     $dir->delete();
                     $dirCount++;
                 } catch (Exception $e) {
                     $message = "Unable to delete directory " . $dir->__toString();
                     if ($this->failonerror) {
                         throw new BuildException($message);
                     } else {
                         $this->log($message, $this->quiet ? Project::MSG_VERBOSE : Project::MSG_WARN);
                     }
                 }
             }
         }
         if ($dirCount > 0) {
             $this->log("Deleted {$dirCount} director" . ($dirCount == 1 ? "y" : "ies") . " from " . $d->__toString());
         }
     }
 }
开发者ID:andrew-ejov,项目名称:start-template,代码行数:51,代码来源:DeleteTask.php

示例11: renameFile

 /**
  * Attempts to rename a file from a source to a destination.
  * If overwrite is set to true, this method overwrites existing file
  * even if the destination file is newer.
  * Otherwise, the source f
  * ile is renamed only if the destination file #
  * is older than it.
  */
 private function renameFile(PhingFile $sourceFile, PhingFile $destFile, $overwrite)
 {
     $renamed = true;
     // ensure that parent dir of dest file exists!
     $parent = $destFile->getParentFile();
     if ($parent !== null) {
         if (!$parent->exists()) {
             $parent->mkdirs();
         }
     }
     if ($destFile->exists()) {
         try {
             $destFile->delete();
         } catch (Exception $e) {
             throw new BuildException("Unable to remove existing file " . $destFile->__toString() . ": " . $e->getMessage());
         }
     }
     $renamed = $sourceFile->renameTo($destFile);
     return $renamed;
 }
开发者ID:sensorsix,项目名称:app,代码行数:28,代码来源:MoveTask.php


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