當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。