本文整理汇总了PHP中Bitrix\Main\IO\File::getFileSize方法的典型用法代码示例。如果您正苦于以下问题:PHP File::getFileSize方法的具体用法?PHP File::getFileSize怎么用?PHP File::getFileSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bitrix\Main\IO\File
的用法示例。
在下文中一共展示了File::getFileSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
/**
* Deletes the file
* with predefined path (current request uri)
*
* @return void
*/
public function delete()
{
if ($this->cacheFile && $this->cacheFile->isExists()) {
$cacheDirectory = $this->cacheFile->getDirectory();
$fileSize = $this->cacheFile->getFileSize();
if (defined("BX_COMPOSITE_DEBUG")) {
$backupName = $this->cacheFile->getPath() . ".delete." . microtime(true);
if ($this->checkQuota()) {
AddMessage2Log($backupName, "composite");
$backupFile = new Main\IO\File($backupName);
$backupFile->putContents($this->cacheFile->getContents());
$this->writeStatistic(0, 0, 0, 0, $fileSize);
} else {
AddMessage2Log($backupName . "(quota exceeded)", "composite");
}
}
$this->cacheFile->delete();
//Try to cleanup directory
$children = $cacheDirectory->getChildren();
if (empty($children)) {
$cacheDirectory->delete();
}
//Update total files size
$this->writeStatistic(0, 0, 0, 0, -$fileSize);
}
}
示例2: reindexFile
private function reindexFile($siteId, $rootPath, $path, $maxFileSize = 0)
{
$pathAbs = IO\Path::combine($rootPath, $path);
if (!UrlRewriter::checkPath($pathAbs)) {
return 0;
}
$file = new IO\File($pathAbs);
if ($maxFileSize > 0 && $file->getFileSize() > $maxFileSize * 1024) {
return 0;
}
$fileSrc = $file->getContents();
if (!$fileSrc || $fileSrc == "") {
return 0;
}
$arComponents = \PHPParser::parseScript($fileSrc);
for ($i = 0, $cnt = count($arComponents); $i < $cnt; $i++) {
$sef = is_array($arComponents[$i]["DATA"]["PARAMS"]) && $arComponents[$i]["DATA"]["PARAMS"]["SEF_MODE"] == "Y";
Component\ParametersTable::add(array('SITE_ID' => $siteId, 'COMPONENT_NAME' => $arComponents[$i]["DATA"]["COMPONENT_NAME"], 'TEMPLATE_NAME' => $arComponents[$i]["DATA"]["TEMPLATE_NAME"], 'REAL_PATH' => $path, 'SEF_MODE' => $sef ? Component\ParametersTable::SEF_MODE : Component\ParametersTable::NOT_SEF_MODE, 'SEF_FOLDER' => $sef ? $arComponents[$i]["DATA"]["PARAMS"]["SEF_FOLDER"] : null, 'START_CHAR' => $arComponents[$i]["START"], 'END_CHAR' => $arComponents[$i]["END"], 'PARAMETERS' => serialize($arComponents[$i]["DATA"]["PARAMS"])));
if ($sef) {
if (array_key_exists("SEF_RULE", $arComponents[$i]["DATA"]["PARAMS"])) {
$ruleMaker = new UrlRewriterRuleMaker();
$ruleMaker->process($arComponents[$i]["DATA"]["PARAMS"]["SEF_RULE"]);
$arFields = array("CONDITION" => $ruleMaker->getCondition(), "RULE" => $ruleMaker->getRule(), "ID" => $arComponents[$i]["DATA"]["COMPONENT_NAME"], "PATH" => $path, "SORT" => self::DEFAULT_SORT);
} else {
$arFields = array("CONDITION" => "#^" . $arComponents[$i]["DATA"]["PARAMS"]["SEF_FOLDER"] . "#", "RULE" => "", "ID" => $arComponents[$i]["DATA"]["COMPONENT_NAME"], "PATH" => $path, "SORT" => self::DEFAULT_SORT);
}
UrlRewriter::add($siteId, $arFields);
}
}
return true;
}
示例3: read
public function read(&$arAllVars, $baseDir, $initDir, $filename, $TTL)
{
$documentRoot = \Bitrix\Main\Application::getDocumentRoot();
$fn = IO\Path::combine($documentRoot, $baseDir, $initDir, $filename);
$file = new IO\File($fn);
if (!$file->isExists()) {
return false;
}
$ser_content = "";
$dateexpire = 0;
$datecreate = 0;
$zeroDanger = false;
$handle = null;
if (is_array($arAllVars)) {
$INCLUDE_FROM_CACHE = 'Y';
if (!(include IO\Path::convertLogicalToPhysical($fn))) {
return false;
}
if ($zeroDanger) {
$ser_content = str_replace("", "*", $ser_content);
}
} else {
if (!$file instanceof IO\IFileStream) {
return false;
}
$handle = $file->open("r");
if (!$handle) {
return false;
}
$datecreate = fread($handle, 2);
if ($datecreate == "BX") {
$datecreate = fread($handle, 12);
$dateexpire = fread($handle, 12);
} else {
$datecreate .= fread($handle, 10);
}
}
/* We suppress warning here in order not to break
the compression under Zend Server */
$this->read = $file->getFileSize();
if (intval($datecreate) < mktime() - $TTL) {
return false;
}
if (is_array($arAllVars)) {
$arAllVars = unserialize($ser_content);
} else {
$arAllVars = fread($handle, $this->read);
fclose($handle);
}
return true;
}