Get the systems temporary directory.

@return string
330903
public static function sys_get_temp_dir()
    {
    // Moodle hack!
    if (function_exists('make_temp_directory')) {
        $temp = make_temp_directory('phpexcel');
        return realpath(dirname($temp));
    }

        if (self::$useUploadTempDirectory) {
            //  use upload-directory when defined to allow running on environments having very restricted
            //      open_basedir configs
            if (ini_get('upload_tmp_dir') !== false) {
                if ($temp = ini_get('upload_tmp_dir')) {
                    if (file_exists($temp)) {
                        return realpath($temp);
                    }
                }
            }
        }

        // sys_get_temp_dir is only available since PHP 5.2.1
        // http://php.net/manual/en/function.sys-get-temp-dir.php#94119
        if (!function_exists('sys_get_temp_dir')) {
            if ($temp = getenv('TMP')) {
                if ((!empty($temp)) && (file_exists($temp))) {
                    return realpath($temp);
                }
            }
            if ($temp = getenv('TEMP')) {
                if ((!empty($temp)) && (file_exists($temp))) {
                    return realpath($temp);
                }
            }
            if ($temp = getenv('TMPDIR')) {
                if ((!empty($temp)) && (file_exists($temp))) {
                    return realpath($temp);
                }
            }

            // trick for creating a file in system's temporary dir
            // without knowing the path of the system's temporary dir
            $temp = tempnam(__FILE__, '');
            if (file_exists($temp)) {
                unlink($temp);
                return realpath(dirname($temp));
            }

            return null;
        }

        // use ordinary built-in PHP function
        //    There should be no problem with the 5.2.4 Suhosin realpath() bug, because this line should only
        //        be called if we're running 5.2.1 or earlier
        return realpath(sys_get_temp_dir());
    }
1132793
public function getTempPath()
    {
        if (is_null($this->_tempPath)) {
            $this->_tempPath = sys_get_temp_dir();
        }
        if (!is_dir($this->_tempPath)) {
            @mkdir($this->_tempPath, 0755, true);
            if (!is_dir($this->_tempPath)) {
                throw new Exception("Unable to create temporary path folder {$this->_tempPath}");
            }
        }

        return $this->_tempPath;
    }
912493
public function generateTempDirectory(): string
    {
        $path = sys_get_temp_dir() . '/'
            . self::TEMP_FILE_OR_DIRECTORY_PREFIX . bin2hex(random_bytes(self::TEMP_DIRECTORY_NAME_LENGTH));
        
        mkdir($path);
        
        register_shutdown_function(function () use ($path) {
            if (!file_exists($path)) {
                return;
            }

            foreach (new \RecursiveIteratorIterator(
                new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS),
                \RecursiveIteratorIterator::CHILD_FIRST
            ) as $file) {
                if ($file->isDir()) {
                    rmdir($file->getPathname());
                } else {
                    unlink($file->getPathname());
                }
            }
            rmdir($path);
        });
        
        return $path;
    }
329933
private function getFilePath()
    {

        $tmpDir = realpath($this->getContainer()->get('kernel')->getRootDir() . '/../var/tmp/');
        $fileName = '/' . str_replace(':', '--', $this->getName()) . '.sock';

        if (!file_exists($tmpDir)) {
            mkdir($tmpDir);
        }

        return $tmpDir . $fileName;
    }
979202
public function getRuntimeDir()
    {
        if (!isset($this->runtimeDir)) {
            $this->runtimeDir = ConfigPaths::getRuntimeDir();
        }

        if (!\is_dir($this->runtimeDir)) {
            \mkdir($this->runtimeDir, 0700, true);
        }

        return $this->runtimeDir;
    }
698283
public function getCacheDir(): string
    {
        if ($this->_cache_dir === null)
            $this->_cache_dir = realpath(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'cache');

        return $this->_cache_dir;
    }
874985
public static function getTempDirectory($blnAppendTrailingSlash)
	{
		$path = self::getBaseDirectory(true) . self::DIRECTORY_NAME_TEMP;
		
		if ($blnAppendTrailingSlash)
		{
			$path .= "/";
		}
		return $path;
	}
121685
public function getRootDir()
    {
        static $dir;
        if (empty($dir)) {
            $rc = new \ReflectionClass(get_class($this));
            $dir = dirname(dirname($rc->getFileName()));
        }
        return $dir;
    }
746740
public function getCacheDir()
    {
        static $dir;
        if (empty($dir)) {
            $dir = $this->getOpenDir() . '/cache/';

            if (!is_dir($dir)) {
                mkdir($dir, 0755, true);
            }
        }
        return $dir;
    }
184834
def gettempdir():
    """"""
    global tempdir
    if tempdir is None:
        _once_lock.acquire()
        try:
            if tempdir is None:
                tempdir = _get_default_tempdir()
        finally:
            _once_lock.release()
    return tempdir
483206
public function getTemporaryDirectory()
    {
        if (!self::$_temporary_directory)
        {
            $result     = false;
            $candidates = array(
                ini_get('upload_tmp_dir'),
                JFactory::getApplication()->getCfg('tmp_path'),
                JPATH_ROOT.'/tmp'
            );

            if (function_exists('sys_get_temp_dir')) {
                array_unshift($candidates, sys_get_temp_dir());
            }

            foreach ($candidates as $folder)
            {
                if ($folder && @is_dir($folder) && is_writable($folder))
                {
                    $result = rtrim($folder, '\\/');
                    break;
                }
            }

            if ($result === false) {
                throw new RuntimeException('Cannot find a writable temporary directory');
            }

            self::$_temporary_directory = $result;
        }

        return self::$_temporary_directory;
    }
116611
protected function getBaseDirectory()
    {
        if (! $this->fileSystem) {
            $this->fileSystem = $this->getServiceLocator()
                ->get(FileSystemService::SERVICE_ID)
                ->getDirectory($this->getFileSystemId());
        }

        return $this->fileSystem;
    }
867849
private static function getTemporaryFile() {
        if(is_callable(self::$temp)) {
            $temporaryFile = @call_user_func(self::$temp);
            if(is_string($temporaryFile) && strlen($temporaryFile) && is_writable($temporaryFile)) {
                return $temporaryFile;
            }
        }
        $temporaryDirectory = (is_string(self::$temp) && strlen(self::$temp)) ? self::$temp : sys_get_temp_dir();
        return tempnam($temporaryDirectory, 'Zip');
    }
348878
protected function getTemporaryDirectory()
    {
        $result = $this->temporaryDirectory;
        if ($result === '') {
            $fileHelper = $this->app->make('helper/file');
            $temporaryDirectory = (string) $fileHelper->getTemporaryDirectory();
            if ($temporaryDirectory === '' || !$this->filesystem->isDirectory($temporaryDirectory)) {
                throw new UserMessageException(t('Unable to determine the temporary directory.'));
            }
            $this->temporaryDirectory = $temporaryDirectory;
        }

        return $this->temporaryDirectory;
    }
208565
public static function getTemporaryDirectory()
    {
        $check = function ($s) {
            $result = '';
            if (is_string($s) && ($s !== '')) {
                $s = @realpath($s);
                if (($s !== false) && is_dir($s) && is_writable(($s))) {
                    $result = $s;
                }
            }

            return $result;
        };
        $result = '';
        if ($result === '') {
            if (static::$temporaryDirectory !== '') {
                $result = $check(static::$temporaryDirectory);
                if ($result === '') {
                    throw new \Exception('The configured temporary directory is not valid');
                }
            }
        }
        if ($result === '') {
            if (function_exists('sys_get_temp_dir')) {
                $result = $check(@sys_get_temp_dir());
            }
        }
        if ($result === '') {
            if (isset($_ENV) && is_array($_ENV)) {
                foreach (array('TMP', 'TMPDIR', 'TEMP') as $k) {
                    if (isset($_ENV[$k])) {
                        $result = $check($_ENV[$k]);
                        if ($result !== '') {
                            break;
                        }
                    }
                }
            }
        }
        if ($result === '') {
            throw new \Exception('Unable to determine a temporary directory');
        }

        return $result;
    }
813967
public function tempnam(): string
    {
        $root = $this->getFsRoot();
        do {
            ++$this->fsCounter;
            $name = $root.'/'.$this->fsCounter;
        } while (file_exists($name));

        return $name;
    }
367116
public function getRootDirModule()
    {
        $r = new \ReflectionObject($this);
        $injectionDir = str_replace('\\', '/', dirname($r->getFileName()));
        return $injectionDir . '/..';
    }