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


PHP DirectoryIterator::getRealPath方法代碼示例

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


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

示例1: patchValidatorXml

 /**
  * @param DirectoryIterator $fileInfo
  */
 private function patchValidatorXml($fileInfo)
 {
     if ($fileInfo->isFile()) {
         $filePath = $fileInfo->getRealPath();
         $content = file_get_contents($filePath);
         $contentMap = ['"DateInterval"' => '"\\Common\\CoreBundle\\Validator\\Constraints\\DateInterval"'];
         $content = str_replace(array_keys($contentMap), array_values($contentMap), $content);
         file_put_contents($filePath, $content);
     }
 }
開發者ID:turnaev,項目名稱:mysql-workbench-schema-exporter,代碼行數:13,代碼來源:Patcher.php

示例2: delete

 public static function delete($dir)
 {
     $dir = new DirectoryIterator($dir);
     foreach ($dir as $file) {
         if ($file->isDot()) {
             continue;
         } else {
             if ($file->isDir()) {
                 self::delete($file->getRealPath());
             } else {
                 if ($file->isFile()) {
                     unlink($file->getRealPath());
                 }
             }
         }
     }
     $dir->rewind();
     rmdir($dir->getRealPath());
 }
開發者ID:bklein01,項目名稱:SiberianCMS,代碼行數:19,代碼來源:Directory.php

示例3: move_dir

 protected static function move_dir($source, $destination, $overwrite)
 {
     if (!self::is_dir($source)) {
         throw new Exception('Only directory must be passed to move_dir() as source');
     }
     if (!self::is_dir($destination)) {
         throw new Exception('Only directory must be passed to move_dir() as destination');
     }
     $basename = pathinfo($source, PATHINFO_BASENAME);
     if (!self::is_dir($destination . '/' . $basename)) {
         if (!mkdir($destination . '/' . $basename, fileperms($source), TRUE)) {
             throw new Exception('Can not create directory ' . $destination . '/' . $basename);
         }
     }
     $dir = new DirectoryIterator($source);
     while ($dir->valid()) {
         if (!$dir->isDot()) {
             self::move($dir->getRealPath(), $destination . '/' . $basename, $overwrite);
         }
         $dir->next();
     }
     self::delete_dir($source);
 }
開發者ID:ariol,項目名稱:adminshop,代碼行數:23,代碼來源:Fs.php

示例4: _delete_file

 /**
  * Deletes files recursively and returns FALSE on any errors
  * 
  *     // Delete a file or folder whilst retaining parent directory and ignore all errors
  *     $this->_delete_file($folder, TRUE, TRUE);
  *
  * @param   SplFileInfo  file
  * @param   boolean  retain the parent directory
  * @param   boolean  ignore_errors to prevent all exceptions interrupting exec
  * @param   boolean  only expired files
  * @return  boolean
  * @throws  Kohana_Cache_Exception
  */
 protected function _delete_file(SplFileInfo $file, $retain_parent_directory = FALSE, $ignore_errors = FALSE, $only_expired = FALSE)
 {
     // Allow graceful error handling
     try {
         // If is file
         if ($file->isFile()) {
             try {
                 // If only expired is not set
                 if ($only_expired === FALSE) {
                     // We want to delete the file
                     $delete = TRUE;
                 } else {
                     // Assess the file expiry to flag it for deletion
                     $json = $file->openFile('r')->current();
                     $data = json_decode($json);
                     $delete = $data->expiry < time();
                 }
                 // If the delete flag is set
                 if ($delete === TRUE) {
                     // Try to delete
                     unlink($file->getRealPath());
                 }
             } catch (ErrorException $e) {
                 // Catch any delete file warnings
                 if ($e->getCode() === E_WARNING) {
                     throw new Kohana_Cache_Exception(__METHOD__ . ' failed to delete file : :file', array(':file' => $file->getRealPath()));
                 }
             }
         } else {
             if ($file->isDir()) {
                 // Create new DirectoryIterator
                 $files = new DirectoryIterator($file->getPathname());
                 // Iterate over each entry
                 while ($files->valid()) {
                     // Extract the entry name
                     $name = $files->getFilename();
                     // If the name is not a dot
                     if ($name != '.' and $name != '..') {
                         // Create new file resource
                         $fp = new SplFileInfo($files->getRealPath());
                         // Delete the file
                         $this->_delete_file($fp);
                     }
                     // Move the file pointer on
                     $files->next();
                 }
                 // If set to retain parent directory, return now
                 if ($retain_parent_directory) {
                     return TRUE;
                 }
                 try {
                     // Remove the files iterator
                     // (fixes Windows PHP which has permission issues with open iterators)
                     unset($files);
                     // Try to remove the parent directory
                     return rmdir($file->getRealPath());
                 } catch (ErrorException $e) {
                     // Catch any delete directory warnings
                     if ($e->getCode() === E_WARNING) {
                         throw new Kohana_Cache_Exception(__METHOD__ . ' failed to delete directory : :directory', array(':directory' => $file->getRealPath()));
                     }
                 }
             }
         }
     } catch (Exception $e) {
         // If ignore_errors is on
         if ($ignore_errors === TRUE) {
             // Return
             return FALSE;
         }
         // Throw exception
         throw $e;
     }
 }
開發者ID:Tidwell,項目名稱:HMXSongs-PHP-API,代碼行數:87,代碼來源:file.php

示例5: _delete_file

 /**
  * Deletes files recursively and returns FALSE on any errors
  * 
  *     // Delete a file or folder whilst retaining parent directory and ignore all errors
  *     $this->_delete_file($folder, TRUE, TRUE);
  *
  * @param   SplFileInfo  file
  * @param   boolean  retain the parent directory
  * @param   boolean  ignore_errors to prevent all exceptions interrupting exec
  * @return  boolean
  * @throws  Kohana_Cache_Exception
  */
 protected function _delete_file(SplFileInfo $file, $retain_parent_directory = FALSE, $ignore_errors = FALSE)
 {
     // Allow graceful error handling
     try {
         // If is file
         if ($file->isFile()) {
             try {
                 // Try to delete
                 unlink($file->getRealPath());
             } catch (ErrorException $e) {
                 // Catch any delete file warnings
                 if ($e->getCode() === E_WARNING) {
                     throw new Kohana_Cache_Exception(__METHOD__ . ' failed to delete file : :file', array(':file' => $file->getRealPath()));
                 }
             }
         } else {
             if ($file->isDir()) {
                 // Create new DirectoryIterator
                 $files = new DirectoryIterator($file->getPathname());
                 // Iterate over each entry
                 while ($files->valid()) {
                     // Extract the entry name
                     $name = $files->getFilename();
                     // If the name is not a dot
                     if ($name != '.' and $name != '..') {
                         // Create new file resource
                         $fp = new SplFileInfo($files->getRealPath());
                         // Delete the file
                         $this->_delete_file($fp);
                     }
                     // Move the file pointer on
                     $files->next();
                 }
                 // If set to retain parent directory, return now
                 if ($retain_parent_directory) {
                     return TRUE;
                 }
                 try {
                     // Try to remove the parent directory
                     return rmdir($file->getRealPath());
                 } catch (ErrorException $e) {
                     // Catch any delete directory warnings
                     if ($e->getCode() === E_WARNING) {
                         throw new Kohana_Cache_Exception(__METHOD__ . ' failed to delete directory : :directory', array(':directory' => $file->getRealPath()));
                     }
                 }
             }
         }
     } catch (Exception $e) {
         // If ignore_errors is on
         if ($ignore_errors === TRUE) {
             // Return
             return FALSE;
         }
         // Throw exception
         throw $e;
     }
 }
開發者ID:shockiii,項目名稱:dedeezy,代碼行數:70,代碼來源:file.php

示例6: _cleanDir

 /**
  * Try to clean directory using recorsion.
  * No ensurance for wrong permissions
  */
 private function _cleanDir(DirectoryIterator $dir)
 {
     X_Debug::i('Cleaning dir ' . $dir->getRealPath());
     foreach ($dir as $entry) {
         /* @var $entry DirectoryIterator */
         if ($entry->isDot()) {
             continue;
         }
         if ($entry->isFile()) {
             @unlink($entry->getRealPath());
         } elseif ($entry->isDir()) {
             $this->_cleanDir($entry);
             @rmdir($entry->getRealPath());
         }
     }
 }
開發者ID:google-code-backups,項目名稱:vlc-shares,代碼行數:20,代碼來源:Egg.php

示例7: _getItemStats

 /**
  * Determine file/directory statistics for input item.
  *
  * @param DirectoryIterator $item Item passed from a DirectoryIterator
  * @return array Listing with stats
  */
 private static function _getItemStats(DirectoryIterator $item)
 {
     $list = array();
     // add filename
     $list['name'] = (string) $item;
     // add directory/file type
     $list['type'] = $item->getType();
     // add modification time
     $list['modified'] = date('Y-m-d H:i:s', $item->getMTime());
     // get permissions
     $list['permissions'] = $item->getPerms();
     // is writable?
     $list['writable'] = $item->isWritable() ? 1 : 0;
     // add path
     $list['path'] = $item->getPathName();
     $list['real_path'] = $item->getRealPath();
     // add size
     $list['size'] = Fari_Format::bytes($item->getSize());
     return $list;
 }
開發者ID:radekstepan,項目名稱:PumpedBlog,代碼行數:26,代碼來源:File.php

示例8: className

 /**
  * Convert a file to class name of the test case class
  *
  * @param	DirectoryIterator		$file		test case file
  * @return	string								test case class name
  */
 private function className($file)
 {
     return str_replace('/', '_', str_replace(array($this->root, '.php'), '', $file->getRealPath()));
 }
開發者ID:RStankov,項目名稱:playground,代碼行數:10,代碼來源:Runner.php

示例9: resolve

 protected function resolve($groups, $input)
 {
     $resolved = array();
     if (strpos($input, '@') === false) {
         return array($this->webdir . '/' . $input);
     }
     $cleaned = str_replace('@', '', $input);
     if (isset($groups[$cleaned])) {
         foreach ($groups[$cleaned]['inputs'] as $candidate) {
             $resolved = array_merge($resolved, $this->resolve($groups, $candidate));
         }
         return $resolved;
     }
     if (($star = strpos($input, '*')) === false) {
         return array($this->kernel->locateResource($input));
     } else {
         $dir = $this->kernel->locateResource(substr($input, 0, $star));
         $it = new \DirectoryIterator($dir);
         foreach ($it as $file) {
             if ($file->isFile()) {
                 array_push($resolved, $it->getRealPath());
             }
         }
     }
     return $resolved;
 }
開發者ID:pladodev,項目名稱:AdminThemeBundle,代碼行數:26,代碼來源:BuildAssetsCommand.php


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