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


PHP UTIL_File::removeLastDS方法代码示例

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


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

示例1: copyDir

 /**
  * Copy folder to cloud storage
  *
  * @param string $sourcePath
  * @param string $destPath
  * @param array $fileTypes
  * @param int $level
  *
  * @return boolean
  */
 public function copyDir($sourcePath, $destPath, array $fileTypes = null, $level = -1)
 {
     $sourcePath = UTIL_File::removeLastDS($sourcePath);
     $destPath = UTIL_File::removeLastDS($destPath);
     if (!UTIL_File::checkDir($sourcePath)) {
         return false;
     }
     if (!$this->fileExists($destPath)) {
         $this->mkdir($destPath);
     }
     $handle = opendir($sourcePath);
     while (($item = readdir($handle)) !== false) {
         if ($item === '.' || $item === '..' || $item === '') {
             continue;
         }
         $path = $sourcePath . DS . $item;
         $dPath = $destPath . DS . $item;
         if (is_file($path)) {
             if ($fileTypes === null || in_array(UTIL_File::getExtension($path), $fileTypes)) {
                 $this->copyFile($path, $dPath);
             }
         } else {
             if ($level && is_dir($path)) {
                 $this->copyDir($path, $dPath, $fileTypes, $level - 1);
             }
         }
     }
     closedir($handle);
     return true;
 }
开发者ID:hardikamutech,项目名称:loov,代码行数:40,代码来源:amazon_cloud_storage.php

示例2: getFileNameList

 public function getFileNameList($dirPath, $prefix = null, array $fileTypes = null)
 {
     $dirPath = UTIL_File::removeLastDS($dirPath);
     $resultList = array();
     $handle = opendir($dirPath);
     while (($item = readdir($handle)) !== false) {
         if ($item === '.' || $item === '..') {
             continue;
         }
         if ($prefix != null) {
             $prefixLength = strlen($prefix);
             if (!($prefixLength <= strlen($item) && substr($item, 0, $prefixLength) === $prefix)) {
                 continue;
             }
         }
         $path = $dirPath . DS . $item;
         if ($fileTypes === null || is_file($path) && in_array(UTIL_File::getExtension($item), $fileTypes)) {
             $resultList[] = $path;
         }
     }
     closedir($handle);
     return $resultList;
 }
开发者ID:vazahat,项目名称:dudex,代码行数:23,代码来源:file_storage.php

示例3: importPrefixFromDir

 /**
  * @param string $path
  * @param bool $refreshCache
  * @param bool $addLanguage
  * @param bool $updateValues
  */
 public function importPrefixFromDir($path, $refreshCache = true, $addLanguage = false, $updateValues = false)
 {
     $path = UTIL_File::removeLastDS($path) . DS;
     if (!UTIL_File::checkDir($path)) {
         throw new InvalidArgumentException("Directory not found : {$path}");
     }
     $arr = glob("{$path}*");
     $prefixesToImport = array();
     $langsToImport = array();
     foreach ($arr as $index => $dir) {
         $dh = opendir($dir);
         if (!file_exists($dir . DS . 'language.xml')) {
             continue;
         }
         $langXmlE = simplexml_load_file($dir . DS . 'language.xml');
         $l = array('label' => strval($langXmlE->attributes()->label), 'tag' => strval($langXmlE->attributes()->tag), 'path' => $dir . DS);
         if (!in_array($l, $langsToImport)) {
             $langsToImport[] = $l;
         }
         /* @var $xmlElement SimpleXMLElement */
         while (false !== ($file = readdir($dh))) {
             if ($file == '.' || $file == '..' || is_dir($dir . DS . $file) || $file == 'language.xml' || !file_exists($dir . DS . $file)) {
                 continue;
             }
             $xmlElement = simplexml_load_file($dir . DS . $file);
             $tmp = $xmlElement->xpath('/prefix');
             $prefixElement = $tmp[0];
             $prefixItem = array('label' => strval($prefixElement->attributes()->label), 'prefix' => strval($prefixElement->attributes()->name));
             if (!in_array($prefixItem, $prefixesToImport)) {
                 $prefixesToImport[] = $prefixItem;
             }
         }
     }
     $languages = $this->getLanguages();
     $activateFirstLang = empty($languages);
     foreach ($langsToImport as $langToImport) {
         if (!$this->findByTag($langToImport['tag'])) {
             if (!$addLanguage) {
                 continue;
             }
             $dto = new BOL_Language();
             $dto->setLabel($langToImport['label'])->setTag($langToImport['tag'])->setStatus($activateFirstLang ? 'active' : 'inactive')->setOrder($this->findMaxOrder() + 1);
             $this->save($dto);
             $activateFirstLang = false;
         }
         foreach ($prefixesToImport as $prefixToImport) {
             $filePath = $langToImport['path'] . "{$prefixToImport['prefix']}.xml";
             if (!file_exists($filePath)) {
                 continue;
             }
             $xml = simplexml_load_file($filePath);
             $this->importPrefix($xml, false, false, $updateValues);
         }
     }
     if ($refreshCache) {
         $this->generateCacheForAllActiveLanguages();
     }
 }
开发者ID:ZyXelP,项目名称:oxwall,代码行数:64,代码来源:language_service.php

示例4: rmDir

 public function rmDir($dirPath)
 {
     $dirPath = $this->getPath($dirPath);
     $dirPath = UTIL_File::removeLastDS($dirPath);
     $dirContent = $this->readDir($dirPath);
     foreach ($dirContent as $dirItem) {
         if ($dirItem['type'] === 'file') {
             $this->delete($dirPath . DS . $dirItem['name']);
         } else {
             $this->rmDir($dirPath . DS . $dirItem['name']);
         }
     }
     ftp_rmdir($this->stream, $dirPath);
 }
开发者ID:ZyXelP,项目名称:oxwall,代码行数:14,代码来源:ftp.php


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