You are here

protected function Local::writeHtaccess in Flysystem 8

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

Writes an .htaccess file.

Parameters

bool $force: Whether to overwrite an existing file.

Return value

bool True on success, false on failure.

2 calls to Local::writeHtaccess()
Local::ensure in src/Flysystem/Local.php
Checks the sanity of the filesystem.
Local::ensureDirectory in src/Flysystem/Local.php
Checks that the directory exists and is readable.

File

src/Flysystem/Local.php, line 169

Class

Local
Drupal plugin for the "Local" Flysystem adapter.

Namespace

Drupal\flysystem\Flysystem

Code

protected function writeHtaccess($force) {
  $htaccess_path = $this->root . '/.htaccess';
  if (file_exists($htaccess_path) && !$force) {

    // Short circuit if the .htaccess file already exists.
    return TRUE;
  }

  // Make file writable so that we can overwrite it.
  if (file_exists($htaccess_path)) {
    chmod($htaccess_path, 0666);
  }
  return @file_put_contents($htaccess_path, FileStorage::htaccessLines(!$this->isPublic)) && chmod($htaccess_path, 0444);
}