本文整理汇总了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);
}
示例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;
}
示例3: rmdir
public function rmdir()
{
$tmpDir = $this->getTmpDir(false);
foreach (glob("{$tmpDir}*") as $dirname) {
@rmdir($dirname);
}
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例10: removeDirs
protected function removeDirs($dirs)
{
$appPath = $this->app['path'];
foreach ($dirs as $dir) {
is_dir($appPath . '/' . $dir) and rmdir($appPath . '/' . $dir);
}
}
示例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);
}
}
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}