You are here

protected function Local::ensureDirectory in Flysystem 7

Same name and namespace in other branches
  1. 8 src/Flysystem/Local.php \Drupal\flysystem\Flysystem\Local::ensureDirectory()
  2. 3.x src/Flysystem/Local.php \Drupal\flysystem\Flysystem\Local::ensureDirectory()
  3. 2.0.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.

Parameters

string $directory: The directory.

Return value

string|false The path of the directory, or 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 167
Contains \Drupal\flysystem\Flysystem\Local.

Class

Local
Drupal plugin for the "Local" Flysystem adapter.

Namespace

Drupal\flysystem\Flysystem

Code

protected function ensureDirectory($directory) {

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