Returns a directory path for temporary files

Additionally checks for Joomla tmp folder if the system directory is not writable

@throws RuntimeException If a temporary writable directory cannot be found
@return string Folder path
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;
    }
716479
protected function getPhp()
    {
        if (is_null($this->php_path)) {
            $finder = new PhpExecutableFinder();
            if (!($this->php_path = $finder->find())) {
                throw new \RuntimeException(
                    'The php executable could not be found, add it to your PATH environment variable and try again'
                );
            }
        }

        return $this->php_path;
    }
502193
public static function getTmpDir()
    {
        if ( self::$tmpDir === null )
        {
            self::$tmpDir = sys_get_temp_dir();
            if ( substr( self::$tmpDir, strlen( self::$tmpDir ) - 1 ) !== DIRECTORY_SEPARATOR )
            {
                self::$tmpDir = self::$tmpDir . DIRECTORY_SEPARATOR;
            }
        }
        return self::$tmpDir;
    }
685678
protected function getDefaultDirectory()
    {
        // Default to ~/.platformsh/.session, but if it's not writable, fall
        // back to the temporary directory.
        $default = $this->getHomeDirectory() . '/.platformsh/.session';
        if ($this->canWrite($default)) {
            return $default;
        }
        $temp = sys_get_temp_dir() . '/.platformsh-client/.session';
        if ($this->canWrite($temp)) {
            return $temp;
        }

        throw new \RuntimeException('Unable to find a writable session storage directory');
    }
794036
protected function getFilePath()
    {
        $path = $this->cachePath . DIRECTORY_SEPARATOR . $this->cacheDirectory . DIRECTORY_SEPARATOR;
        $path = str_replace(['\\\\', '//'], [DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR], $path);

        return $path;
    }
952646
public function getBinDir(): string
    {
        $binDir = $this->config->getBinDir();
        if (!$this->fileSystem->exists($binDir)) {
            throw new RuntimeException('The configured BIN directory could not be found.');
        }

        return $this->getRelativePath($binDir);
    }
1170
public function getTempDirectory()
    {
        if (!file_exists($this->tempDirectory)) {
            mkdir($this->tempDirectory, 0777);
            chmod($this->tempDirectory, 0777);
        }

        return $this->tempDirectory;
    }
901477
public function getRuntimePath()
    {
        $paths = [];
        foreach ($this->getRuntime() as $key => $value) {
            if (in_array($key, ['hook', 'libraries', 'stylesheets', 'mediaFiles', 'icon', 'src'])) {
                $paths[$key] = preg_replace('/^' . $this->getTypeIdentifier() . '/', '.', $value);
            }
        }
        return $paths;
    }
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;
    }
150255
public function getFilepath()
    {
        if (isset($this->dirPath)) {
            $filepath = $this->dirPath .'/'.$this->filename;
        } else {
            $fileSystem = $this->createNew(FileSystem::class);
            $filepath   = $fileSystem->getCurrentWorkingDirectory() .'/'.$this->filename;    
        }
        return $filepath;        
    }
335494
public static File getTempDirectory() {
	if (tempFile != null) return tempFile;

	final String tmpStr = System.getProperty("java.io.tmpdir");
	if (tmpStr != null) {
	    tempFile = new File(tmpStr);
	    if (tempFile.exists()) {
		tempFile = getCanonicalFileEL(tempFile);
		return tempFile;
	    }
	}
	try {
	    final File tmp = File.createTempFile("a", "a");
	    tempFile = tmp.getParentFile();
	    tempFile = getCanonicalFileEL(tempFile);
	    tmp.delete();
	}
	catch (final IOException ioe) {}

	return tempFile;
    }
531205
public function getDirectory() : string
    {
        if (! is_string($this->file)) {
            throw new RuntimeException(
                'Module file to parse has not determined yet.',
                E_WARNING
            );
        }

        return dirname($this->file);
    }
44245
protected String getDirectory() {
        //get the default filepath of the permanet storage file
        String directory = storageConfiguration.getDirectory();

        if(directory == null || directory.isEmpty()) {
            directory = System.getProperty("java.io.tmpdir"); //write them to the tmp directory
        }

        return directory;
    }
123427
public function getLogPath(): string
    {
        $path = $this->getRuntimePath() . DIRECTORY_SEPARATOR . 'logs';
        FileHelper::createDirectory($path);
        return $path;
    }
311112
private function getDirectory()
    {
        // Fallback to default directory if no storage path defined
        if (defined('CRAFT_STORAGE_PATH')) {
            $basePath = CRAFT_STORAGE_PATH;
        } else {
            $basePath = CRAFT_BASE_PATH . DIRECTORY_SEPARATOR . 'storage';
        }

        return $basePath . DIRECTORY_SEPARATOR . 'runtime' . DIRECTORY_SEPARATOR . 'htmlcache' . DIRECTORY_SEPARATOR;
    }
1272085
protected function getCacheDirectory()
    {
        $cache_dir = false;

        if ($this->cacheDir && is_dir($this->cacheDir)) {
            $twig_cache = $this->cacheDir . self::CACHE_DIR;
            if (is_dir($twig_cache) && is_writable($twig_cache)) {
                $cache_dir = $twig_cache;
            } else {

                // Attempt to create twig cache dir
                $fs = new FileSystem();

                try {
                    $fs->mkdir($twig_cache);
                } catch (\Exception $e) {}

                $cache_dir = $twig_cache;
            }
        }

        return($cache_dir);
    }
633549
public function getRuntimePath(): string
    {
        if ($this->_runtimePath !== null) {
            return $this->_runtimePath;
        }
        $runtimePath = Yii::getAlias('@runtime');

        if ($runtimePath === false) {
            throw new Exception('There was a problem getting the vendor path.');
        }
        return $this->_runtimePath = FileHelper::normalizePath($runtimePath);
    }