Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

rrmdir()

Description

Recursively remove a folder and its contents. Paths to ignore can be specified.

Parameters

ColumnTypeDefaultDescription
$dir string The folder to delete.
$ignore_dirs array array An optional array of folders to ignore.

Return

null

Location

include/file_functions.php lines 210 to 234

Definition

 
function rrmdir($dir,$ignore_dirs=array())
    { 
    if (
is_dir($dir))
        { 
        
$objects scandir($dir);
        foreach (
$objects as $object)
            { 
            if (
$object != "." && $object != "..")
                { 
                if (
is_dir($dir"/" .$object) && !is_link($dir."/".$object))
                    {
                    
rrmdir($dir"/" .$object,$ignore_dirs);
                    }
                else
                    {
                    
unlink($dir"/" .$object); 
                    }
                } 
            }
        if (!
in_array($dir,$ignore_dirs))
            {
            
debug("system_reset: remove directory " $dir);
            }
        }
    }

This article was last updated 11th April 2022 10:05 Europe/London time based on the source file dated 11th April 2022 09:55 Europe/London time.