You are here

public function vfsStreamWrapper::rmdir in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamWrapper.php \org\bovigo\vfs\vfsStreamWrapper::rmdir()

removes a directory

@todo consider $options with STREAM_MKDIR_RECURSIVE

Parameters

string $path:

int $options:

Return value

bool

1 call to vfsStreamWrapper::rmdir()
vfsStreamWrapperRecordingProxy::rmdir in vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/proxy/vfsStreamWrapperRecordingProxy.php
removes a directory
1 method overrides vfsStreamWrapper::rmdir()
vfsStreamWrapperRecordingProxy::rmdir in vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/proxy/vfsStreamWrapperRecordingProxy.php
removes a directory

File

vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamWrapper.php, line 891

Class

vfsStreamWrapper
Stream wrapper to mock file system requests.

Namespace

org\bovigo\vfs

Code

public function rmdir($path, $options) {
  $path = $this
    ->resolvePath(vfsStream::path($path));
  $child = $this
    ->getContentOfType($path, vfsStreamContent::TYPE_DIR);
  if (null === $child) {
    return false;
  }

  // can only remove empty directories
  if (count($child
    ->getChildren()) > 0) {
    return false;
  }
  if (self::$root
    ->getName() === $path) {

    // delete root? very brave. :)
    self::$root = null;
    clearstatcache();
    return true;
  }
  $names = $this
    ->splitPath($path);
  $dir = $this
    ->getContentOfType($names['dirname'], vfsStreamContent::TYPE_DIR);
  if ($dir
    ->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup()) === false) {
    return false;
  }
  clearstatcache();
  return $dir
    ->removeChild($child
    ->getName());
}