Exemple #1
0
 /**
  * Remove directory
  *
  * @param boolean $recursive (empty directory contents and remove)
  * @return boolean
  */
 public function remove($recursive = false)
 {
     if (!$this->__isDir()) {
         return false;
     }
     if (!$recursive) {
         if (!@rmdir($this->_path)) {
             $this->error = parent::_getLastError();
             return false;
         }
         return true;
     }
     // recursive remove
     foreach ($this->read(false, true) as $asset) {
         if ($asset['type'] === 'dir') {
             $dir = new Directory($this->_path . $asset['name'], false);
             if (!$dir->remove(true)) {
                 $this->error = 'Failed to remove subdirectory \'' . $dir->getPath() . '\' (' . $dir->error . '), try elevated chmod';
                 return false;
             }
         } else {
             $file = new File($this->_path . $asset['name'], false);
             if (!$file->remove()) {
                 $this->error = 'Failed to remove file \'' . $file->getPath() . '\' (' . $file->error . '), try elevated chmod';
                 return false;
             }
         }
     }
     return $this->remove();
     // finally remove base directory
 }
Exemple #2
0
 /**
  * File is writable flag getter
  *
  * @return boolean
  */
 public function writable()
 {
     if ($this->exists()) {
         return parent::writable();
     }
     // new file, check if directory writable
     return $this->__getDir()->writable();
 }