I was hoping someone could give me a hand, I'm trying to create a delete
folders function that recursively deletes folders and files from a given
directory. Here's what I have so far, but its not working I keep getting 

Warning: rmdir(wwwroot/resources/applications/44/series/25/modules/29)
[function.rmdir]: Directory not empty in
wwwroot\common\class.directories.php on line 28

function deleteFolders( $resource )
{
        if( is_dir( $resource ) )
        {
                if( $dir = opendir( $resource ) )
                {
                        while( false !== ( $file == readdir( $dir ) ) )
                        {
                                if( $file != '.' && $file != '..' )
                                {
        
$this->deleteFolders($resource.'/'.$file );
                                }
                        }
                        closedir($dir);
                        rmdir($resource);
                }
                else 
                {
                        $this->LOG .= __LINE__ . ": Unable to open
directory\r\n";
                }
        }
        else 
        {
                
                if( is_file( $resource ) )
                {                               
                        unlink( $resource );
                }
                else 
                {
                        $this->LOG .= __LINE__ . ": Unknown path:
$resource\r\n";
                }
        }
}

TIA, mark

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to