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


PHP removeDir函数代码示例

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


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

示例1: removeDir

function removeDir($path)
{
    // Add trailing slash to $path if one is not there
    if (substr($path, -1, 1) != "/") {
        $path .= "/";
    }
    $files = glob($path . "*");
    if (count($files) > 0) {
        foreach ($files as $file) {
            if (is_file($file) === true) {
                // Remove each file in this Directory
                if (unlink($file) === false) {
                    return false;
                }
            } else {
                if (is_dir($file) === true) {
                    // If this Directory contains a Subdirectory, run this Function on it
                    if (removeDir($file) == false) {
                        return false;
                    }
                }
            }
        }
    }
    // Remove Directory once Files have been removed (If Exists)
    if (is_dir($path) === true) {
        if (rmdir($path) == false) {
            return false;
        }
    }
    return true;
}
开发者ID:alx,项目名称:blogsfera,代码行数:32,代码来源:clean-sessions.php

示例2: test_clean

function test_clean()
{
    logTestMessage(NEW_LINE_LOG . " >> Cleanup all test users...");
    removeDir(USER_DIR);
    // including files
    logTestMessage("End cleanup");
}
开发者ID:einervonvielen,项目名称:mushrooms,代码行数:7,代码来源:test_util.php

示例3: removeDir

/**
 * Recursively delete a directory
 *
 * @param string $path Intial path to delete
 */
function removeDir($path)
{
    $normal_files = glob($path . "*");
    $hidden_files = glob($path . "\\.?*");
    $all_files = array_merge($normal_files, $hidden_files);
    foreach ($all_files as $file) {
        /* Skip pseudo links to current and parent dirs (./ and ../). */
        if (preg_match("/(\\.|\\.\\.)\$/", $file)) {
            continue;
        }
        if (is_file($file) === TRUE) {
            /* Remove each file in this Directory */
            unlink($file);
            echo _gettext('Removed File') . ': ' . $file . "<br />";
        } else {
            if (is_dir($file) === TRUE) {
                /* If this Directory contains a Subdirectory, run this Function on it */
                removeDir($file);
            }
        }
    }
    /* Remove Directory once Files have been removed (If Exists) */
    if (is_dir($path) === TRUE) {
        rmdir($path);
        echo '<br />' . _gettext('Removed Directory') . ': ' . $path . "<br /><br />";
    }
}
开发者ID:stormeus,项目名称:Kusaba-Z,代码行数:32,代码来源:directories.php

示例4: removeDir

function removeDir($dir)
{
    if (file_exists($dir)) {
        // create directory pointer
        $dp = opendir($dir) or die('ERROR: Cannot open directory');
        // read directory contents
        // delete files found
        // call itself recursively if directories found
        while ($file = readdir($dp)) {
            if ($file != '.' && $file != '..') {
                if (is_file("{$dir}/{$file}")) {
                    unlink("{$dir}/{$file}");
                } else {
                    if (is_dir("{$dir}/{$file}")) {
                        removeDir("{$dir}/{$file}");
                    }
                }
            }
        }
        // close directory pointer
        closedir($dp);
        // remove now-empty directory
        if (rmdir($dir)) {
            return true;
        } else {
            return false;
        }
    }
}
开发者ID:rajesh38,项目名称:file-dbms,代码行数:29,代码来源:delete_db.php

示例5: checkIsEmpty

 public function checkIsEmpty($ftp, $ftp_folder, $file)
 {
     $directory = explode('/', $file);
     if (count($directory) > 1) {
         unset($directory[count($directory) - 1]);
         $path = implode('/', $directory);
         removeDir($ftp_folder, $path, $ftp);
     }
 }
开发者ID:fernandocchaves,项目名称:ftpdeploy,代码行数:9,代码来源:FTPDeploy.php

示例6: deleteAction

 public function deleteAction()
 {
     if ($this->getConfig()->get('default_layout') == $this->getRequest()->getParam('key')) {
         $this->addMessage('cantDeleteDefaultLayout');
     } else {
         removeDir(APPLICATION_PATH . '/layouts/' . $this->getRequest()->getParam('key'));
         $this->addMessage('deleteSuccess');
     }
     $this->redirect(array('action' => 'index'));
 }
开发者ID:prepare4battle,项目名称:Ilch-2.0,代码行数:10,代码来源:Layouts.php

示例7: removeDir

function removeDir($dir)
{
    if (!file_exists($dir)) {
        return false;
    }
    $files = array_diff(scandir($dir), array('.', '..'));
    foreach ($files as $file) {
        is_dir("{$dir}/{$file}") && !is_link($dir) ? removeDir("{$dir}/{$file}") : unlink("{$dir}/{$file}");
    }
    return rmdir($dir);
}
开发者ID:EmranAhmed,项目名称:envato-watermark-image-replacement,代码行数:11,代码来源:process.php

示例8: removeDir

function removeDir($path)
{
    foreach (glob($path . "/*") as $file) {
        if (is_dir($file)) {
            removeDir($file);
        } else {
            unlink($file);
        }
    }
    rmdir($path);
}
开发者ID:KiyotaMahiro,项目名称:eTextLogger,代码行数:11,代码来源:epub_unzipper.php

示例9: removeDir

function removeDir($path)
{
    // Normalise $path.
    $path = rtrim($path, '/') . '/';
    // Remove all child files and directories.
    $items = glob($path . '*');
    foreach ($items as $item) {
        is_dir($item) ? removeDir($item) : unlink($item);
    }
    // Remove directory.
    rmdir($path);
}
开发者ID:Nguyenkain,项目名称:hanghieusales,代码行数:12,代码来源:wp-update.php

示例10: removeDir

 function removeDir($path)
 {
     $dir = new DirectoryIterator($path);
     foreach ($dir as $fileinfo) {
         if ($fileinfo->isFile() || $fileinfo->isLink()) {
             unlink($fileinfo->getPathName());
         } elseif (!$fileinfo->isDot() && $fileinfo->isDir()) {
             removeDir($fileinfo->getPathName());
         }
     }
     rmdir($path);
 }
开发者ID:AndreyLikhoman,项目名称:electrotopka,代码行数:12,代码来源:tg_themegloballite_settings.php

示例11: deleteAction

 public function deleteAction()
 {
     $modules = new \Modules\Admin\Mappers\Module();
     $key = $this->getRequest()->getParam('key');
     if ($this->getRequest()->isSecure()) {
         $configClass = '\\Modules\\' . ucfirst($key) . '\\Config\\config';
         $config = new $configClass($this->getTranslator());
         $config->uninstall();
         $modules->delete($key);
         removeDir(APPLICATION_PATH . '/modules/' . $this->getRequest()->getParam('key'));
         $this->addMessage('deleteSuccess');
     }
     $this->redirect(array('action' => 'index'));
 }
开发者ID:prepare4battle,项目名称:Ilch-2.0,代码行数:14,代码来源:Modules.php

示例12: my_delete

/**
 * Delete a file or a directory
 *
 * @author - Hugues Peeters
 * @param  - $file (String) - the path of file or directory to delete
 * @return - bolean - true if the delete succeed
 *           bolean - false otherwise.
 * @see    - delete() uses check_name_exist() and removeDir() functions
 */
function my_delete($file)
{
    if (check_name_exist($file)) {
        if (is_file($file)) {
            unlink($file);
            return true;
        } elseif (is_dir($file)) {
            removeDir($file);
            return true;
        }
    } else {
        return false;
        // no file or directory to delete
    }
}
开发者ID:BackupTheBerlios,项目名称:migueloo,代码行数:24,代码来源:fileManageLib.inc.php

示例13: cherry_restore_callback

function cherry_restore_callback()
{
    $theme_folder = isset($_GET['theme_folder']) ? $_GET['theme_folder'] : '';
    if (!$theme_folder) {
        wp_die('File not provided', 'Error');
    }
    $file = str_replace('\\', '/', WP_CONTENT_DIR) . '/themes_backup/' . $theme_folder . ".zip";
    $themes_folder = str_replace('\\', '/', get_theme_root()) . '/' . $theme_folder;
    if (file_exists($file)) {
        removeDir($themes_folder);
        cherry_unzip_backup($file, $themes_folder);
    } else {
        echo theme_locals("unfortunately") . $theme_folder . theme_locals("please_try");
    }
}
开发者ID:drupalninja,项目名称:schome_org,代码行数:15,代码来源:restore.php

示例14: removeDir

 function removeDir($dirName)
 {
     if (!is_dir($dirName)) {
         return @unlink($dirName);
     }
     $handle = @opendir($dirName);
     while (($file = @readdir($handle)) !== false) {
         if ($file != '.' && $file != '..') {
             $dir = $dirName . '/' . $file;
             is_dir($dir) ? removeDir($dir) : @unlink($dir);
         }
     }
     closedir($handle);
     return true;
 }
开发者ID:rohcirtep,项目名称:easygameengine,代码行数:15,代码来源:ToolboxAction.class.php

示例15: removeDir

function removeDir($dir)
{
    if (is_dir($dir)) {
        $files = scandir($dir);
        foreach ($files as $file) {
            if ($file != "." && $file != "..") {
                removeDir("{$dir}/{$file}");
            }
        }
        rmdir($dir);
    } else {
        if (file_exists($dir)) {
            unlink($dir);
        }
    }
}
开发者ID:sathish-m,项目名称:CSV-Upload,代码行数:16,代码来源:FormatAndMove.php


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