/**
  * Will delete a directory and all files and directories inside of it
  *
  * This operation will not be performed until the filesystem transaction
  * has been committed, if a transaction is in progress. Any non-Flourish
  * code (PHP or system) will still see this directory and all contents as
  * existing until that point.
  *
  * @return void
  */
 public function delete()
 {
     if ($this->deleted) {
         return;
     }
     if (!$this->getParent()->isWritable()) {
         throw new fEnvironmentException('The directory, %s, can not be deleted because the directory containing it is not writable', $this->directory);
     }
     $files = $this->scan();
     foreach ($files as $file) {
         $file->delete();
     }
     // Allow filesystem transactions
     if (fFilesystem::isInsideTransaction()) {
         return fFilesystem::recordDelete($this);
     }
     rmdir($this->directory);
     fFilesystem::updateDeletedMap($this->directory, debug_backtrace());
     fFilesystem::updateFilenameMapForDirectory($this->directory, '*DELETED at ' . time() . ' with token ' . uniqid('', TRUE) . '* ' . $this->directory);
 }
Example #2
0
 /**
  * Deletes the current file
  * 
  * This operation will NOT be performed until the filesystem transaction
  * has been committed, if a transaction is in progress. Any non-Flourish
  * code (PHP or system) will still see this file as existing until that
  * point.
  * 
  * @return void
  */
 public function delete()
 {
     // The only kind of stored exception is if the file has already
     // been deleted so in that case nothing needs to be done
     if ($this->exception) {
         return;
     }
     if (!$this->getDirectory()->isWritable()) {
         throw new fEnvironmentException('The file, %s, can not be deleted because the directory containing it is not writable', $this->file);
     }
     // Allow filesystem transactions
     if (fFilesystem::isInsideTransaction()) {
         return fFilesystem::recordDelete($this);
     }
     unlink($this->file);
     $exception = new fProgrammerException('The action requested can not be performed because the file has been deleted');
     fFilesystem::updateExceptionMap($this->file, $exception);
 }