public function __destruct() { try { FileUtils::removeDirectory($this->path, true); } catch (BaseException $e) { // boo! deal with garbage yourself. } }
public function drop() { // removed, but not created yet if (!is_writable($this->path)) { return true; } $toRemove = realpath($this->path) . '.' . microtime(true) . getmypid() . '.' . '.removing'; try { rename($this->path, $toRemove); } catch (BaseException $e) { // already removed during race return true; } FileUtils::removeDirectory($toRemove, true); return true; }
/** * @return RubberFileSystem **/ public function clean() { // just to return 'true' FileUtils::removeDirectory($this->directory, true); return parent::clean(); }
public function __construct($directory = '/temp-garbage/', $prefix = 'TmpFile') { $this->path = FileUtils::makeTempFile($directory, $prefix); }