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


PHP VQMod::_folderChecks方法代碼示例

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


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

示例1: modCheck

 /**
  * VQMod::modCheck()
  *
  * @param string $sourceFile path for file
  * @return string
  * @description Checks if a file has modifications and applies them, returning cache files or the file name
  */
 public static function modCheck($sourceFile)
 {
     if (!self::$_folderChecks) {
         if (self::$logging) {
             // Create log folder if it doesn't exist
             $log_folder = self::path(self::$logFolder, true);
             self::dirCheck($log_folder);
         }
         // Create cache folder if it doesn't exist
         $cache_folder = self::path(self::$vqCachePath, true);
         self::dirCheck($cache_folder);
         // Store cache folder path to save on repeat checks for path validity
         self::$_cachePathFull = self::path(self::$vqCachePath);
         self::$_folderChecks = true;
     }
     if (!preg_match('%^([a-z]:)?[\\\\/]%i', $sourceFile)) {
         $sourcePath = self::path($sourceFile);
     } else {
         $sourcePath = self::_realpath($sourceFile);
     }
     if (!$sourcePath || is_dir($sourcePath) || in_array($sourcePath, self::$_doNotMod)) {
         return $sourceFile;
     }
     $stripped_filename = preg_replace('~^' . preg_quote(self::getCwd(), '~i') . '~', '', $sourcePath);
     $cacheFile = self::_cacheName($stripped_filename);
     $file_last_modified = filemtime($sourcePath);
     if (file_exists($cacheFile) && filemtime($cacheFile) >= self::$_lastModifiedTime && filemtime($cacheFile) >= $file_last_modified) {
         return $cacheFile;
     }
     if (isset(self::$_filesModded[$sourcePath])) {
         return self::$_filesModded[$sourcePath]['cached'] ? $cacheFile : $sourceFile;
     }
     $changed = false;
     $fileHash = sha1_file($sourcePath);
     $fileData = file_get_contents($sourcePath);
     foreach (self::$_mods as $modObject) {
         foreach ($modObject->mods as $path => $mods) {
             if (self::_checkMatch($path, $sourcePath)) {
                 $modObject->applyMod($mods, $fileData);
             }
         }
     }
     if (sha1($fileData) != $fileHash) {
         $writePath = $cacheFile;
         if (!file_exists($writePath) || is_writable($writePath)) {
             file_put_contents($writePath, $fileData);
             $changed = true;
         }
     }
     self::$_filesModded[$sourcePath] = array('cached' => $changed);
     return $changed ? $writePath : $sourcePath;
 }
開發者ID:honeynatividad,項目名稱:mircatu,代碼行數:59,代碼來源:vqmod.php


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