You are here

protected function Local::ensureDirectory in Flysystem 2.0.x

Same name and namespace in other branches
  1. 8 src/Flysystem/Local.php \Drupal\flysystem\Flysystem\Local::ensureDirectory()
  2. 7 src/Flysystem/Local.php \Drupal\flysystem\Flysystem\Local::ensureDirectory()
  3. 3.x src/Flysystem/Local.php \Drupal\flysystem\Flysystem\Local::ensureDirectory()
  4. 3.0.x src/Flysystem/Local.php \Drupal\flysystem\Flysystem\Local::ensureDirectory()

Checks that the directory exists and is readable.

This will attempt to create the directory if it doesn't exist.

Return value

bool True on success, false on failure.

1 call to Local::ensureDirectory()
Local::__construct in src/Flysystem/Local.php
Constructs a Local object.

File

src/Flysystem/Local.php, line 147

Class

Local
Drupal plugin for the "Local" Flysystem adapter.

Namespace

Drupal\flysystem\Flysystem

Code

protected function ensureDirectory() {

  // Go for the success case first.
  if (is_dir($this->root) && is_readable($this->root)) {
    return TRUE;
  }
  if (!file_exists($this->root)) {
    mkdir($this->root, $this->directoryPerm, TRUE);
  }
  if (is_dir($this->root) && chmod($this->root, $this->directoryPerm)) {
    clearstatcache(TRUE, $this->root);
    $this
      ->writeHtaccess(TRUE);
    return TRUE;
  }
  return FALSE;
}