本文整理匯總了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;
}