CFile::delete PHP Method

delete() public method

For folders purge parameter can be supplied.
public delete ( boolean $purge = True ) : boolean
$purge boolean If 'True' folder would be deleted with all the descendants
return boolean 'True' if successfully deleted, 'False' on fail
    public function delete($purge = True)
    {
        if ($this->getWriteable()) {
            if ($this->getIsFile() && @unlink($this->_realpath) || !$this->getIsFile() && ($purge ? $this->purge() : True) && @rmdir($this->_realpath)) {
                $this->_exists = $this->_readable = $this->_writeable = False;
                return True;
            }
        }
        $this->addLog('Unable to delete filesystem object');
        return False;
    }

Usage Example

 /**
  * @see parent::delete()
  */
 function delete()
 {
     // Suppression du fichier correspondant
     if ($this->file_id) {
         $this->loadFile();
         if ($this->_ref_file->file_id) {
             $this->_ref_file->delete();
         }
     }
     //suppression de la doc
     return parent::delete();
 }
All Usage Examples Of CFile::delete