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


PHP RecursiveIteratorIterator::isLink方法代码示例

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


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

示例1: rmdir

 /**
  * Remove recursively the directory named by dirname.
  *
  * @param string $dirname       Path to the directory
  * @param boolean $followLinks  Removes symbolic links if set to true
  * @return boolean              True if success otherwise false
  * @throws Exception            When the directory does not exist or permission denied
  */
 public static function rmdir($dirname, $followLinks = false)
 {
     if (!is_dir($dirname) && !is_link($dirname)) {
         throw new Exception(sprintf('Directory %s does not exist', $dirname));
     }
     if (!is_writable($dirname)) {
         throw new Exception('You do not have renaming permissions');
     }
     $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirname), RecursiveIteratorIterator::CHILD_FIRST);
     while ($iterator->valid()) {
         if (!$iterator->isDot()) {
             if (!$iterator->isWritable()) {
                 throw new Exception(sprintf('Permission denied for %s', $iterator->getPathName()));
             }
             if ($iterator->isLink() && false === (bool) $followLinks) {
                 $iterator->next();
                 continue;
             }
             if ($iterator->isFile()) {
                 unlink($iterator->getPathName());
             } else {
                 if ($iterator->isDir()) {
                     rmdir($iterator->getPathName());
                 }
             }
         }
         $iterator->next();
     }
     unset($iterator);
     return rmdir($dirname);
 }
开发者ID:rom1git,项目名称:Centurion,代码行数:39,代码来源:System.php

示例2: recursive_rmdir

 private function recursive_rmdir($dirname, $followLinks = false)
 {
     if (is_dir($dirname) && !is_link($dirname)) {
         if (!is_writable($dirname)) {
             throw new Exception('You do not have renaming permissions!');
         }
         $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirname), RecursiveIteratorIterator::CHILD_FIRST);
         while ($iterator->valid()) {
             if (!$iterator->isDot()) {
                 if (!$iterator->isWritable()) {
                     throw new Exception(sprintf('Permission Denied: %s.', $iterator->getPathName()));
                 }
                 if ($iterator->isLink() && false === (bool) $followLinks) {
                     $iterator->next();
                 }
                 if ($iterator->isFile()) {
                     unlink($iterator->getPathName());
                 } else {
                     if ($iterator->isDir()) {
                         rmdir($iterator->getPathName());
                     }
                 }
             }
             $iterator->next();
         }
         unset($iterator);
         // Fix for Windows.
         return rmdir($dirname);
     } else {
         throw new Exception(sprintf('Directory %s does not exist!', $dirname));
     }
 }
开发者ID:jadnx,项目名称:VulnerabilityAssessmentWebTool,代码行数:32,代码来源:FileManagerModel.php

示例3: RecursiveRmdir

 /**
  * Recursively remove a directory
  *
  * @param string $dirname
  * @param boolean $followSymlinks
  * @return boolean
  */
 function RecursiveRmdir($dirname, $followSymlinks = false)
 {
     if (is_dir($dirname) && !is_link($dirname)) {
         if (!is_writable($dirname)) {
             throw new \Exception(sprintf('%s is not writable!', $dirname));
         }
         $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dirname), \RecursiveIteratorIterator::CHILD_FIRST);
         while ($iterator->valid()) {
             if (!$iterator->isDot()) {
                 if (!$iterator->isWritable()) {
                     throw new \Exception(sprintf('%s is not writable!', $iterator->getPathName()));
                 }
                 if ($iterator->isLink() && $followLinks === false) {
                     $iterator->next();
                 }
                 if ($iterator->isFile()) {
                     @unlink($iterator->getPathName());
                 } elseif ($iterator->isDir()) {
                     @rmdir($iterator->getPathName());
                 }
             }
             $iterator->next();
         }
         unset($iterator);
         return @rmdir($dirname);
     } else {
         throw new \Exception(sprintf('%s does not exist!', $dirname));
     }
 }
开发者ID:BionicClick,项目名称:PHPoole,代码行数:36,代码来源:phpoole.php


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