当前位置: 首页>>代码示例>>PHP>>正文


PHP File::delete方法代码示例

本文整理汇总了PHP中Bitrix\Main\IO\File::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP File::delete方法的具体用法?PHP File::delete怎么用?PHP File::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Bitrix\Main\IO\File的用法示例。


在下文中一共展示了File::delete方法的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);
     }
 }
开发者ID:spas-viktor,项目名称:books,代码行数:32,代码来源:statichtmlcache.php

示例2: delete

 /**
  * Deletes TmpFile.
  * The method attempts to destroy content (cloud or file from file system).
  * @return bool
  */
 public function delete()
 {
     if ($this->isCloud()) {
         $bucket = $this->getBucket();
         if (!$bucket) {
             return false;
         }
         if (!$bucket->deleteFile($this->path)) {
             $this->errorCollection->addOne(new Error('Could not delete file from bucket.', static::ERROR_DELETE_CLOUD_FILE));
             return false;
         }
     } else {
         $file = new IO\File($this->getAbsolutePath());
         if ($file->isExists()) {
             if (!$file->delete()) {
                 $this->errorCollection->addOne(new Error('Could not delete file.', static::ERROR_DELETE_FILE));
                 return false;
             }
         }
     }
     return $this->deleteInternal();
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:27,代码来源:tmpfile.php

示例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);
     }
 }
开发者ID:,项目名称:,代码行数:52,代码来源:


注:本文中的Bitrix\Main\IO\File::delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。