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


PHP Folder::dirsize方法代码示例

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


在下文中一共展示了Folder::dirsize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: read

 public function read($path)
 {
     $dir = new Folder($path);
     $read = $dir->read();
     $result = [];
     foreach ($read[0] as $folder) {
         $info = new Folder($path . DS . $folder);
         $reference = Router::fullBaseUrl() . '/' . $this->toRelative($path . '/' . $folder);
         $data = ['name' => $folder, 'type' => 'folder', 'path' => $path . DS . $folder, 'reference' => $reference, 'extension' => 'folder', 'size' => $info->dirsize()];
         $result[] = $data;
     }
     foreach ($read[1] as $file) {
         $info = new File($path . DS . $file, false);
         $reference = Router::fullBaseUrl() . '/' . $this->toRelative($path . '/' . $file);
         $data = ['name' => $info->info()['basename'], 'type' => 'file', 'path' => $path, 'reference' => $reference, 'extension' => $info->info()['extension'], 'size' => $info->info()['filesize']];
         $result[] = $data;
     }
     return $result;
 }
开发者ID:cakemanager,项目名称:cakeadmin-filemanager,代码行数:19,代码来源:FileManagerComponent.php

示例2: main

 /**
  * main method
  *
  * @param  string $tempDir an other directory to clear of all folders and files, if desired
  * @return void
  */
 public function main($tempDir = null)
 {
     if (empty($tempDir)) {
         $tempDir = Configure::read('Attachments.tmpUploadsPath');
     }
     if (!Folder::isAbsolute($tempDir)) {
         $this->out('The path must be absolute, "' . $tempDir . '" given.');
         exit;
     }
     $Folder = new Folder();
     if ($Folder->cd($tempDir) === false) {
         $this->out('Path "' . $tempDir . '" doesn\'t seem to exist.');
         exit;
     }
     $dir = new Folder($tempDir);
     $folders = $dir->read();
     $files = $dir->findRecursive();
     $deletedFiles = 0;
     $deletedFolders = 0;
     $this->out('Found ' . count($folders[0]) . ' folders and ' . count($files) . ' files');
     foreach ($files as $filePath) {
         $file = new File($filePath);
         // only delete if last change is longer than 24 hours ago
         if ($file->lastChange() < time() - 24 * 60 * 60 && $file->delete()) {
             $deletedFiles++;
         }
         $file->close();
     }
     foreach ($folders[0] as $folderName) {
         $folder = new Folder($dir->pwd() . $folderName);
         // only delete if folder is empty
         if ($folder->dirsize() === 0 && $folder->delete()) {
             $deletedFolders++;
         }
     }
     $this->out('Deleted ' . $deletedFolders . ' folders and ' . $deletedFiles . ' files.');
 }
开发者ID:cleptric,项目名称:cake-attachments,代码行数:43,代码来源:CleanTempShell.php


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