本文整理汇总了PHP中Bitrix\Main\IO\File::rename方法的典型用法代码示例。如果您正苦于以下问题:PHP File::rename方法的具体用法?PHP File::rename怎么用?PHP File::rename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bitrix\Main\IO\File
的用法示例。
在下文中一共展示了File::rename方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: finish
public function finish()
{
foreach ($this->partList as $key => $partName) {
$f = new File(Path::combine($this->getDirectoryName(), $partName));
$f->rename(str_replace($this->getPrefix(), '', $f->getPath()));
$this->partList[$key] = $f->getName();
}
if ($this->isCurrentPartNotEmpty()) {
$this->addFooter();
$this->rename(str_replace($this->getPrefix(), '', $this->getPath()));
}
}
示例2: prepareDataToInsertFromFileArray
protected static function prepareDataToInsertFromFileArray(array $fileData, array $data, ErrorCollection $errorCollection)
{
list($relativePath, $absolutePath) = self::generatePath();
$file = new IO\File($fileData['tmp_name']);
if (!$file->isExists()) {
$errorCollection->addOne(new Error('Could not find file', self::ERROR_EXISTS_FILE));
return null;
}
if (!$file->rename($absolutePath)) {
$errorCollection->addOne(new Error('Could not move file', self::ERROR_MOVE_FILE));
return null;
}
//now you can set CREATED_BY
$data = array_intersect_key($data, array('CREATED_BY' => true));
return array_merge(array('TOKEN' => bx_basename($relativePath), 'FILENAME' => $fileData['name'], 'PATH' => $relativePath, 'BUCKET_ID' => '', 'SIZE' => '', 'IS_CLOUD' => '', 'WIDTH' => empty($fileData['width']) ? '' : $fileData['width'], 'HEIGHT' => empty($fileData['height']) ? '' : $fileData['height']), $data);
}
示例3: write
public function write($arAllVars, $baseDir, $initDir, $filename, $TTL)
{
$documentRoot = \Bitrix\Main\Application::getDocumentRoot();
$fn = IO\Path::combine($documentRoot, $baseDir, $initDir, $filename);
$file = new IO\File($fn);
$fnTmp = IO\Path::combine($documentRoot, $baseDir, $initDir, md5(mt_rand()) . ".tmp");
$fileTmp = new IO\File($fnTmp);
$dir = $file->getDirectory();
if (!$dir->isExists()) {
$dir->create();
}
if (is_array($arAllVars)) {
$contents = "<?";
$contents .= "\nif(\$INCLUDE_FROM_CACHE!='Y')return false;";
$contents .= "\n\$datecreate = '" . str_pad(mktime(), 12, "0", STR_PAD_LEFT) . "';";
$contents .= "\n\$dateexpire = '" . str_pad(mktime() + IntVal($TTL), 12, "0", STR_PAD_LEFT) . "';";
$v = serialize($arAllVars);
if (static::checkZeroDanger()) {
$v = str_replace("*", "", $v);
$contents .= "\n\$zeroDanger = true;";
}
$contents .= "\n\$ser_content = '" . str_replace("'", "\\'", str_replace("\\", "\\\\", $v)) . "';";
$contents .= "\nreturn true;";
$contents .= "\n?>";
} else {
$contents = "BX" . str_pad(mktime(), 12, "0", STR_PAD_LEFT) . str_pad(mktime() + IntVal($this->TTL), 12, "0", STR_PAD_LEFT);
$contents .= $arAllVars;
}
$this->written = $fileTmp->putContents($contents);
$len = \Bitrix\Main\Text\String::strlenBytes($contents);
//This checks for Zend Server CE in order to supress warnings
if (function_exists('accelerator_reset')) {
try {
$file->delete();
} catch (\Exception $ex) {
}
} elseif ($file->isExists()) {
$file->delete();
}
if ($this->written === $len) {
$fileTmp->rename($fn);
}
//This checks for Zend Server CE in order to supress warnings
if (function_exists('accelerator_reset')) {
try {
IO\File::deleteFile($fnTmp);
} catch (\Exception $ex) {
}
} elseif (IO\File::isFileExists($fnTmp)) {
IO\File::deleteFile($fnTmp);
}
}