function FileSystemInterface::prepareDirectory

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/File/FileSystemInterface.php \Drupal\Core\File\FileSystemInterface::prepareDirectory()
  2. 10 core/lib/Drupal/Core/File/FileSystemInterface.php \Drupal\Core\File\FileSystemInterface::prepareDirectory()
  3. 11.x core/lib/Drupal/Core/File/FileSystemInterface.php \Drupal\Core\File\FileSystemInterface::prepareDirectory()

Checks that the directory exists and is writable.

Directories need to have execute permissions to be considered a directory by FTP servers, etc.


string $directory: A string reference containing the name of a directory path or URI. A trailing slash will be trimmed from a path.

int $options: A bitmask to indicate if the directory should be created if it does not exist (FileSystemInterface::CREATE_DIRECTORY) or made writable if it is read-only (FileSystemInterface::MODIFY_PERMISSIONS).

Return value

bool TRUE if the directory exists (or was created) and is writable. FALSE otherwise.

1 method overrides FileSystemInterface::prepareDirectory()
FileSystem::prepareDirectory in core/lib/Drupal/Core/File/FileSystem.php
Checks that the directory exists and is writable.


core/lib/Drupal/Core/File/FileSystemInterface.php, line 434


Provides an interface for helpers that operate on files and stream wrappers.




public function prepareDirectory(&$directory, $options = self::MODIFY_PERMISSIONS);

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.