コード例 #1
0
ファイル: graph_export.php プロジェクト: songchin/Cacti
function del_directory($path, $deldir = true) {
	/* $path to the directory to delete or clean */
    /* $deldir (optionnal parameter, true as default) delete the diretory (true) or just clean it (false) */

    /* check if the directory name have a "/" at the end, add if not */
    if ($path[strlen($path)-1] != "/")
	    $path .= "/";
    if (is_dir($path)) {
	    $d = opendir($path);
        while ($f = readdir($d)) {
	        if ($f != "." && $f != "..") {
		        $rf = $path . $f;

				 /* if it is a directory, recursive call to the function */
                if (is_dir($rf)) {
                    del_directory($rf);
                }else {
                    unlink($rf);
				}
            }
        }
        closedir($d);

		/* if $deldir is true, remove the directory */
        if ($deldir) {
            rmdir($path);
		}
 	}
}
コード例 #2
0
ファイル: graph_export.php プロジェクト: songchin/Cacti
function del_directory($path, $deldir = true)
{
    /* check if the directory name have a "/" at the end, add if not */
    if ($path[strlen($path) - 1] != "/") {
        $path .= "/";
    }
    /* cascade through the directory structure(s) until they are all delected */
    if (is_dir($path)) {
        $d = opendir($path);
        while ($f = readdir($d)) {
            if ($f != "." && $f != "..") {
                $rf = $path . $f;
                /* if it is a directory, recursive call to the function */
                if (is_dir($rf)) {
                    del_directory($rf);
                } else {
                    unlink($rf);
                }
            }
        }
        closedir($d);
        /* if $deldir is true, remove the directory */
        if ($deldir) {
            rmdir($path);
        }
    }
}