public function emptyDir($remove = false, $path = null)
    {
        if (null === $path) {
            $path = $this->path;
        }
        // Get a directory handle.
        if (!$dh = @opendir($path)) {
            return;
        }

        // Recursively dig through the directory, deleting files where applicable.
        while (false !== ($obj = readdir($dh))) {
            if ($obj == '.' || $obj == '..') {
                continue;
            }
            if (!@unlink($path . DIRECTORY_SEPARATOR . $obj)) {
                $this->emptyDir(true, $path . DIRECTORY_SEPARATOR . $obj);
            }
        }

        // Close the directory handle.
        closedir($dh);

        // If the delete flag was passed, remove the top level directory.
        if ($remove) {
            @rmdir($path);
        }
    }
public function emptyDir($remove = false, $path = null)
    {
        if (null === $path) {
            $path = $this->path;
        }
        // Get a directory handle.
        if (!$dh = @opendir($path)) {
            return;
        }

        // Recursively dig through the directory, deleting files where applicable.
        while (false !== ($obj = readdir($dh))) {
            if ($obj == '.' || $obj == '..') {
                continue;
            }
            if (!@unlink($path . DIRECTORY_SEPARATOR . $obj)) {
                $this->emptyDir(true, $path . DIRECTORY_SEPARATOR . $obj);
            }
        }

        // Close the directory handle.
        closedir($dh);

        // If the delete flag was passed, remove the top level directory.
        if ($remove) {
            @rmdir($path);
        }
    }
public function emptyDir ( $ remove = false , $ path = null ) { if ( null === $ path ) { $ path = $ this -> path ; } // Get a directory handle. if ( ! $ dh = @ opendir ( $ path ) ) { return ; } // Recursively dig through the directory, deleting files where applicable. while ( false !== ( $ obj = readdir ( $ dh ) ) ) { if ( $ obj == '.' || $ obj == '..' ) { continue ; } if ( ! @ unlink ( $ path . DIRECTORY_SEPARATOR . $ obj ) ) { $ this -> emptyDir ( true , $ path . DIRECTORY_SEPARATOR . $ obj ) ; } } // Close the directory handle. closedir ( $ dh ) ; // If the delete flag was passed, remove the top level directory. if ( $ remove ) { @ rmdir ( $ path ) ; } }
Empty an entire directory

@param  boolean $remove
@param  string  $path
@return void
Empty an entire directory