Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. FileSystem.php

class FileSystem

Same name in this branch
  1. 11.1.x vendor/phpunit/php-code-coverage/src/Util/Filesystem.php \SebastianBergmann\CodeCoverage\Util\Filesystem
  2. 11.1.x vendor/phpunit/phpunit/src/Util/Filesystem.php \PHPUnit\Util\Filesystem
  3. 11.1.x vendor/php-tuf/composer-stager/src/Internal/Filesystem/Service/Filesystem.php \PhpTuf\ComposerStager\Internal\Filesystem\Service\Filesystem
  4. 11.1.x vendor/composer/composer/src/Composer/Util/Filesystem.php \Composer\Util\Filesystem
  5. 11.1.x vendor/symfony/filesystem/Filesystem.php \Symfony\Component\Filesystem\Filesystem
  6. 11.1.x core/lib/Drupal/Core/File/FileSystem.php \Drupal\Core\File\FileSystem

Provides file system functions.

Hierarchy

  • class \Drupal\Component\FileSystem\FileSystem

Expanded class hierarchy of FileSystem

5 files declare their use of FileSystem
DiskSpaceValidator.php in core/modules/package_manager/src/Validator/DiskSpaceValidator.php
FileSystem.php in core/lib/Drupal/Core/File/FileSystem.php
PhpExtensionsValidator.php in core/modules/package_manager/src/Validator/PhpExtensionsValidator.php
system.install in core/modules/system/system.install
Install, update and uninstall functions for the system module.
TestDatabase.php in core/lib/Drupal/Core/Test/TestDatabase.php
2 string references to 'FileSystem'
RepositoryFactory::configFromString in vendor/composer/composer/src/Composer/Repository/RepositoryFactory.php
RepositoryFactory::createRepos in vendor/composer/composer/src/Composer/Repository/RepositoryFactory.php

File

core/lib/Drupal/Component/FileSystem/FileSystem.php, line 10

Namespace

Drupal\Component\FileSystem
View source
class FileSystem {
    
    /**
     * Discovers a writable system-appropriate temporary directory.
     *
     * @return string|false
     *   A string containing the path to the temporary directory, or FALSE if no
     *   suitable temporary directory can be found.
     */
    public static function getOsTemporaryDirectory() {
        $directories = [];
        // Has PHP been set with an upload_tmp_dir?
        if (ini_get('upload_tmp_dir')) {
            $directories[] = ini_get('upload_tmp_dir');
        }
        // Operating system specific dirs.
        if (str_starts_with(PHP_OS, 'WIN')) {
            $directories[] = 'c:\\windows\\temp';
            $directories[] = 'c:\\winnt\\temp';
        }
        else {
            $directories[] = '/tmp';
        }
        // PHP may be able to find an alternative tmp directory.
        $directories[] = sys_get_temp_dir();
        foreach ($directories as $directory) {
            if (is_dir($directory) && is_writable($directory)) {
                // Both sys_get_temp_dir() and ini_get('upload_tmp_dir') can return paths
                // with a trailing directory separator.
                return rtrim($directory, DIRECTORY_SEPARATOR);
            }
        }
        return FALSE;
    }

}

Members

Title Sort descending Modifiers Object type Summary
FileSystem::getOsTemporaryDirectory public static function Discovers a writable system-appropriate temporary directory.
RSS feed
Powered by Drupal