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


PHP FileManager::enough_size方法代码示例

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


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

示例1: import_package


//.........这里部分代码省略.........
     $this->subdir .= '/' . dirname($shortest_path);
     // Do not concatenate because already done above.
     $manifest = $shortest_path;
     if ($this->debug > 1) {
         error_log('New LP - Package type is now ' . $package_type, 0);
     }
     // && defined('CHECK_FOR_SCORM') && CHECK_FOR_SCORM)
     if ($package_type == '') {
         if ($this->debug > 1) {
             error_log('New LP - Package type is empty', 0);
         }
         return api_failure::set_failure('not_scorm_content');
     }
     // It happens on Linux that $new_dir sometimes doesn't start with '/'
     if ($new_dir[0] != '/') {
         $new_dir = '/' . $new_dir;
     }
     if ($new_dir[strlen($new_dir) - 1] == '/') {
         $new_dir = substr($new_dir, 0, -1);
     }
     $isDir = is_dir($course_sys_dir . $new_dir);
     if ($isDir == false) {
         mkdir($course_sys_dir . $new_dir, api_get_permissions_for_new_directories());
         $isDir = is_dir($course_sys_dir . $new_dir);
     }
     /* Uncompressing phase */
     /*
         We need to process each individual file in the zip archive to
         - add it to the database
         - parse & change relative html links
         - make sure the filenames are secure (filter funny characters or php extensions)
     */
     if ($isDir) {
         if (!FileManager::enough_size($realFileSize, $course_sys_dir, $maxFilledSpace)) {
             if ($this->debug > 1) {
                 error_log('New LP - Not enough space to store package', 0);
             }
             return api_failure::set_failure('not_enough_space');
         }
         // PHP method - slower...
         if ($this->debug >= 1) {
             error_log('New LP - Changing dir to ' . $course_sys_dir . $new_dir, 0);
         }
         $saved_dir = getcwd();
         chdir($course_sys_dir . $new_dir);
         $unzippingState = $zipFile->extract();
         for ($j = 0; $j < count($unzippingState); $j++) {
             $state = $unzippingState[$j];
             // TODO: Fix relative links in html files (?)
             $extension = strrchr($state['stored_filename'], '.');
             if ($this->debug >= 1) {
                 error_log('New LP - found extension ' . $extension . ' in ' . $state['stored_filename'], 0);
             }
         }
         if (!empty($new_dir)) {
             $new_dir = $new_dir . '/';
         }
         // Rename files, for example with \\ in it.
         if ($this->debug >= 1) {
             error_log('New LP - try to open: ' . $course_sys_dir . $new_dir, 0);
         }
         if ($dir = @opendir($course_sys_dir . $new_dir)) {
             if ($this->debug >= 1) {
                 error_log('New LP - Opened dir ' . $course_sys_dir . $new_dir, 0);
             }
             while ($file = readdir($dir)) {
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:67,代码来源:scorm.class.php

示例2: import_package


//.........这里部分代码省略.........
                 if ($this->debug > 3) {
                     error_log('New LP - aicc::import_package() - File ' . $thisContent['filename'] . ' didnt match any check', 0);
                 }
             }
         }
         $realFileSize += $thisContent['size'];
     }
     if ($this->debug > 2) {
         error_log('New LP - aicc::import_package() - $files_found: ' . print_r($files_found, true), 0);
     }
     if ($this->debug > 1) {
         error_log('New LP - aicc::import_package() - Package type is now ' . $package_type, 0);
     }
     $mandatory = false;
     foreach ($files_found as $file_name => $file_exts) {
         $temp = (!empty($files_found[$file_name]['crs']) and !empty($files_found[$file_name]['au']) and !empty($files_found[$file_name]['des']) and !empty($files_found[$file_name]['cst']));
         if ($temp) {
             if ($this->debug > 1) {
                 error_log('New LP - aicc::import_package() - Found all config files for ' . $file_name, 0);
             }
             $mandatory = true;
             $package = $file_name;
             // Store base config file name for reuse in parse_config_files().
             $this->config_basename = $file_name;
             // Store filenames for reuse in parse_config_files().
             $this->config_files = $files_found[$file_name];
             // Get out, we only want one config files set.
             break;
         }
     }
     if ($package_type == '' || !$mandatory) {
         return api_failure::set_failure('not_aicc_content');
     }
     if (!FileManager::enough_size($realFileSize, $course_sys_dir, $maxFilledSpace)) {
         return api_failure::set_failure('not_enough_space');
     }
     // It happens on Linux that $new_dir sometimes doesn't start with '/'
     if ($new_dir[0] != '/') {
         $new_dir = '/' . $new_dir;
     }
     // Cut trailing slash.
     if ($new_dir[strlen($new_dir) - 1] == '/') {
         $new_dir = substr($new_dir, 0, -1);
     }
     /* Uncompressing phase */
     /*
         We need to process each individual file in the zip archive to
         - add it to the database
         - parse & change relative html links
         - make sure the filenames are secure (filter funny characters or php extensions)
     */
     if (is_dir($course_sys_dir . $new_dir) or @mkdir($course_sys_dir . $new_dir, api_get_permissions_for_new_directories())) {
         // PHP method - slower...
         if ($this->debug >= 1) {
             error_log('New LP - Changing dir to ' . $course_sys_dir . $new_dir, 0);
         }
         $saved_dir = getcwd();
         chdir($course_sys_dir . $new_dir);
         $unzippingState = $zipFile->extract();
         for ($j = 0; $j < count($unzippingState); $j++) {
             $state = $unzippingState[$j];
             // TODO: Fix relative links in html files (?)
             $extension = strrchr($state["stored_filename"], '.');
             //if ($this->debug > 1) { error_log('New LP - found extension '.$extension.' in '.$state['stored_filename'], 0); }
         }
         if (!empty($new_dir)) {
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:67,代码来源:aicc.class.php


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