/** * Remove a file or folder * @param string/driverFileManagerFile $name File or folder to remove * @param boolean $recursive Delete childs recursively. If is a folder and not empty, remove content? * @return boolean TRUE if Ok. */ public function rm($name, $recursive = false) { if (!is_a($name, 'driverFileManagerFile')) { driverFileManager::clearName($name); $child = $this->getChilds($name, false); if (count($child) == 0) { return false; } else { $child = $child[0]; } } else { $child = $name; // I only can remove my childs. if ($child->getParent() != $this->id) { return false; } } $subChildsCnt = $child->getChildsCount(false); if ($subChildsCnt > 0) { if (!$recursive) { return false; } else { // I get childs that the user can see $subChilds = $child->getChilds('*', true); foreach ($subChilds as $subChild) { // Childs can be files or folders $resp = $child->rm($subChild, $recursive); if (!$resp) { return false; } } // At the end, if I have childs then I cant erase it. $subChildsCnt = $child->getChildsCount(false); if ($subChildsCnt > 0) { return false; } } } return driverFileManager::rmFileEntity($child); }