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


PHP rmdir函数代码示例

本文整理汇总了PHP中rmdir函数的典型用法代码示例。如果您正苦于以下问题:PHP rmdir函数的具体用法?PHP rmdir怎么用?PHP rmdir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: oos_unlink_temp_dir

/**
 * Unlinks all subdirectories and files in $dir
 * Works only on one subdir level, will not recurse
 */
function oos_unlink_temp_dir($dir)
{
    $h1 = opendir($dir);
    while ($subdir = readdir($h1)) {
        // Ignore non directories
        if (!is_dir($dir . $subdir)) {
            continue;
        }
        // Ignore . and .. and CVS
        if ($subdir == '.' || $subdir == '..' || $subdir == 'CVS' || $subdir == '.svn') {
            continue;
        }
        // Loop and unlink files in subdirectory
        $h2 = opendir($dir . $subdir);
        while ($file = readdir($h2)) {
            if ($file == '.' || $file == '..') {
                continue;
            }
            @unlink($dir . $subdir . '/' . $file);
        }
        closedir($h2);
        @rmdir($dir . $subdir);
    }
    closedir($h1);
}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:29,代码来源:download.php

示例2: recursive_remove_directory

/**
 * Recursively delete an entire directory.
 *
 * @since 4.6
 * @package all
 * @param string $directory The dir you want to remove.
 * @param bool $empty Should the dir remain empty?
 * @return bool
 */
function recursive_remove_directory($directory, $empty = false)
{
    if (substr($directory, -1) == '/') {
        $directory = substr($directory, 0, -1);
    }
    if (!file_exists($directory) || !is_dir($directory)) {
        return false;
    } elseif (is_readable($directory)) {
        $handle = opendir($directory);
        while (false !== ($item = readdir($handle))) {
            if ($item != '.' && $item != '..') {
                $path = $directory . '/' . $item;
                if (is_dir($path)) {
                    recursive_remove_directory($path);
                } else {
                    unlink($path);
                }
            }
        }
        closedir($handle);
        if (!$empty) {
            if (!rmdir($directory)) {
                return false;
            }
        }
    }
    return true;
}
开发者ID:billcreswell,项目名称:plucke,代码行数:37,代码来源:functions.all.php

示例3: rmdir

 public function rmdir()
 {
     $tmpDir = $this->getTmpDir(false);
     foreach (glob("{$tmpDir}*") as $dirname) {
         @rmdir($dirname);
     }
 }
开发者ID:hjr3,项目名称:zf2,代码行数:7,代码来源:TestCommonBackend.php

示例4: w_rmdir_recursive_inner

function w_rmdir_recursive_inner($path)
{
    # avoid opening a handle on the dir in case that impacts
    # delete latency on windows
    if (@rmdir($path) || @unlink($path)) {
        return true;
    }
    clearstatcache();
    if (is_dir($path)) {
        # most likely failure reason is that the dir is not empty
        $kids = @scandir($path);
        if (is_array($kids)) {
            foreach ($kids as $kid) {
                if ($kid == '.' || $kid == '..') {
                    continue;
                }
                w_rmdir_recursive($path . DIRECTORY_SEPARATOR . $kid);
            }
        }
        if (is_dir($path)) {
            return @rmdir($path);
        }
    }
    if (is_file($path)) {
        return unlink($path);
    }
    return !file_exists($path);
}
开发者ID:iamchenxin,项目名称:watchman,代码行数:28,代码来源:WatchmanDirectoryFixture.php

示例5: recursiveRemDir

 function recursiveRemDir($directory, $empty = FALSE)
 {
     if (substr($directory, -1) == '/') {
         $directory = substr($directory, 0, -1);
     }
     if (!file_exists($directory) || !is_dir($directory)) {
         return FALSE;
     } elseif (is_readable($directory)) {
         $handle = opendir($directory);
         while (FALSE !== ($item = readdir($handle))) {
             if ($item != '.' && $item != '..') {
                 $path = $directory . '/' . $item;
                 if (is_dir($path)) {
                     Y::recursiveRemDir($path);
                 } else {
                     unlink($path);
                 }
             }
         }
         closedir($handle);
         if ($empty == FALSE) {
             if (!rmdir($directory)) {
                 return FALSE;
             }
         }
     }
     return TRUE;
 }
开发者ID:ASDAFF,项目名称:RosYama.2,代码行数:28,代码来源:Y.php

示例6: osc_deleteDir

/**
 * Tries to delete the directory recursivaly.
 * @return true on success.
 */
function osc_deleteDir($path)
{
    if (!is_dir($path)) {
        return false;
    }
    $fd = @opendir($path);
    if (!$fd) {
        return false;
    }
    while ($file = @readdir($fd)) {
        if ($file != '.' && $file != '..') {
            if (!is_dir($path . '/' . $file)) {
                if (!@unlink($path . '/' . $file)) {
                    closedir($fd);
                    return false;
                } else {
                    osc_deleteDir($path . '/' . $file);
                }
            } else {
                osc_deleteDir($path . '/' . $file);
            }
        }
    }
    closedir($fd);
    return @rmdir($path);
}
开发者ID:hashemgamal,项目名称:OSClass,代码行数:30,代码来源:utils.php

示例7: tearDown

 /**
  * Destroys the test directory.
  */
 protected function tearDown()
 {
     unlink($this->path . '/a');
     unlink($this->path . '/sub/b');
     rmdir($this->path . '/sub');
     rmdir($this->path);
 }
开发者ID:sqon,项目名称:sqon,代码行数:10,代码来源:DirectoryIteratorTest.php

示例8: clearDirectory

 /**
  * Clear all files in a given directory.
  *
  * @param  string An absolute filesystem path to a directory.
  *
  * @return void
  */
 public static function clearDirectory($directory)
 {
     if (!is_dir($directory)) {
         return;
     }
     // open a file point to the cache dir
     $fp = opendir($directory);
     // ignore names
     $ignore = array('.', '..', 'CVS', '.svn');
     while (($file = readdir($fp)) !== false) {
         if (!in_array($file, $ignore)) {
             if (is_link($directory . '/' . $file)) {
                 // delete symlink
                 unlink($directory . '/' . $file);
             } else {
                 if (is_dir($directory . '/' . $file)) {
                     // recurse through directory
                     self::clearDirectory($directory . '/' . $file);
                     // delete the directory
                     rmdir($directory . '/' . $file);
                 } else {
                     // delete the file
                     unlink($directory . '/' . $file);
                 }
             }
         }
     }
     // close file pointer
     closedir($fp);
 }
开发者ID:Daniel-Marynicz,项目名称:symfony1-legacy,代码行数:37,代码来源:sfToolkit.class.php

示例9: filterLoad

 public function filterLoad(AssetInterface $asset)
 {
     $pb = $this->createProcessBuilder($this->nodeBin ? array($this->nodeBin, $this->emberBin) : array($this->emberBin));
     $templateName = basename($asset->getSourcePath());
     $inputDirPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid('input_dir');
     $inputPath = $inputDirPath . DIRECTORY_SEPARATOR . $templateName;
     $outputPath = tempnam(sys_get_temp_dir(), 'output');
     mkdir($inputDirPath);
     file_put_contents($inputPath, $asset->getContent());
     $pb->add($inputPath)->add('-f')->add($outputPath);
     if ($this->includeBaseDir) {
         $pb->add('-b')->add($inputDirPath . DIRECTORY_SEPARATOR);
     }
     $process = $pb->getProcess();
     $returnCode = $process->run();
     unlink($inputPath);
     rmdir($inputDirPath);
     if (127 === $returnCode) {
         throw new \RuntimeException('Path to node executable could not be resolved.');
     }
     if (0 !== $returnCode) {
         if (file_exists($outputPath)) {
             unlink($outputPath);
         }
         throw FilterException::fromProcess($process)->setInput($asset->getContent());
     }
     if (!file_exists($outputPath)) {
         throw new \RuntimeException('Error creating output file.');
     }
     $compiledJs = file_get_contents($outputPath);
     unlink($outputPath);
     $asset->setContent($compiledJs);
 }
开发者ID:gsomoza,项目名称:TimeTracking,代码行数:33,代码来源:EmberPrecompileFilter.php

示例10: removeDirs

 protected function removeDirs($dirs)
 {
     $appPath = $this->app['path'];
     foreach ($dirs as $dir) {
         is_dir($appPath . '/' . $dir) and rmdir($appPath . '/' . $dir);
     }
 }
开发者ID:kapv89,项目名称:doctrinator,代码行数:7,代码来源:DirectoryGenerationTest.php

示例11: delete

 /**
  * Delete a folder (and all files and folders below it)
  * @param string $path Path to folder to be deleted
  * @param bool $deleteSelf true if the folder should be deleted. false if just its contents.
  * @return int|bool Returns the total of deleted files/folder. Returns false if delete failed
  */
 public function delete($path, $deleteSelf = true)
 {
     if (file_exists($path)) {
         //delete all sub folder/files under, then delete the folder itself
         if (is_dir($path)) {
             if ($path[strlen($path) - 1] != '/' && $path[strlen($path) - 1] != '\\') {
                 $path .= DIRECTORY_SEPARATOR;
                 $path = str_replace('\\', '/', $path);
             }
             if ($total = $this->purgeContent($path)) {
                 if ($deleteSelf) {
                     if ($t = rmdir($path)) {
                         return $total + $t;
                     }
                 }
                 return $total;
             } else {
                 if ($deleteSelf) {
                     return rmdir($path);
                 }
             }
             return false;
         } else {
             return unlink($path);
         }
     }
 }
开发者ID:garv347,项目名称:swanhart-tools,代码行数:33,代码来源:DooFile.php

示例12: tearDown

 /**
  * Tears down the fixture, for example, close a network connection.
  * This method is called after a test is executed.
  */
 protected function tearDown()
 {
     if (file_exists($this->zf2rapidValidatorDir . $this->zf2rapidValidatorFile)) {
         unlink($this->zf2rapidValidatorDir . $this->zf2rapidValidatorFile);
     }
     rmdir($this->zf2rapidValidatorDir);
 }
开发者ID:nomaanp,项目名称:zf2rapid,代码行数:11,代码来源:ValidatorExistsTest.php

示例13: saveRenditions

 public function saveRenditions($renditions, $dir)
 {
     if ($dir[strlen($dir) - 1] !== '/') {
         $dir .= '/';
     }
     $retval = array();
     $tmpdir = '';
     foreach ($renditions as $name => $file) {
         $remote_file = $dir . basename($file);
         $this->save($file, $remote_file);
         $retval[$name] = $remote_file;
         // Remove the temporary file
         if (file_exists($file)) {
             unlink($file);
         } else {
             $log = new api_log();
             $log->warn("storage_driver_s3::saveRenditions() - No temp file for rendition '%s' at '%s'", $name, $file);
         }
         if (empty($tmpdir)) {
             $tmpdir = dirname($file);
         }
     }
     if ($tmpdir !== '') {
         // Optimistic removal. If it's not empty, this will fail.
         @rmdir($tmpdir);
         if (file_exists($tmpdir)) {
             $log = new api_log();
             $log->warn("storage_driver_s3::saveRenditions() - unable to remove rendition tmpdir '%s'", $tmpdir);
         }
     }
     return $retval;
 }
开发者ID:pneff,项目名称:binarypool,代码行数:32,代码来源:storage_driver_s3.php

示例14: full_rmdir

function full_rmdir($dir)
{
    if (!is_writable($dir)) {
        if (!@chmod($dir, WT_PERM_EXE)) {
            return false;
        }
    }
    $d = dir($dir);
    while (false !== ($entry = $d->read())) {
        if ($entry == '.' || $entry == '..') {
            continue;
        }
        $entry = $dir . '/' . $entry;
        if (is_dir($entry)) {
            if (!full_rmdir($entry)) {
                return false;
            }
            continue;
        }
        if (!@unlink($entry)) {
            $d->close();
            return false;
        }
    }
    $d->close();
    rmdir($dir);
    return TRUE;
}
开发者ID:brambravo,项目名称:webtrees,代码行数:28,代码来源:admin_site_clean.php

示例15: files_remove_directory

/**
 * Рекурсивно удаляет директорию
 * @param string $directory
 * @param bool $is_clear Если TRUE, то директория будет очищена, но не удалена
 * @return bool
 */
function files_remove_directory($directory, $is_clear = false)
{
    if (substr($directory, -1) == '/') {
        $directory = substr($directory, 0, -1);
    }
    if (!file_exists($directory) || !is_dir($directory) || !is_readable($directory)) {
        return false;
    }
    $handle = opendir($directory);
    while (false !== ($node = readdir($handle))) {
        if ($node != '.' && $node != '..') {
            $path = $directory . '/' . $node;
            if (is_dir($path)) {
                if (!files_remove_directory($path)) {
                    return false;
                }
            } else {
                if (!@unlink($path)) {
                    return false;
                }
            }
        }
    }
    closedir($handle);
    if ($is_clear == false) {
        if (!@rmdir($directory)) {
            return false;
        }
    }
    return true;
}
开发者ID:pin-git,项目名称:icms2,代码行数:37,代码来源:files.helper.php


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