Horde_Vfs_Base::emptyFolder PHP Method

emptyFolder() public method

Recursively remove all files and subfolders from the given folder.
public emptyFolder ( string $path )
$path string The path of the folder to empty.
    public function emptyFolder($path)
    {
        // Get and delete the subfolders.
        foreach ($this->listFolder($path, null, true, true) as $folder) {
            $this->deleteFolder($path, $folder['name'], true);
        }
        // Only files are left, get and delete them.
        foreach ($this->listFolder($path) as $file) {
            $this->deleteFile($path, $file['name']);
        }
    }

Usage Example

Example #1
0
 /**
  */
 public function clear()
 {
     try {
         $this->_vfs->emptyFolder($this->_params['vfspath']);
     } catch (Horde_Vfs_Exception $e) {
     }
 }