Create a temporary directory, no trailing slash!

@return string
163351
protected function createTmpDir() {

		$temp_file = tempnam( sys_get_temp_dir(), '' );
		@unlink( $temp_file ); // @codingStandardsIgnoreLine
		mkdir( $temp_file );
		if ( ! is_dir( $temp_file ) ) {
			return '';

		}

		return untrailingslashit( $temp_file );
	}
194474
public function makeDirectory($mode = FileSystemPermission::NORMAL)
    {
        $directoryId = $this->generateId();
        $path = sys_get_temp_dir() . '/' . $directoryId;
        $directory = new TemporaryDirectory($path, $mode);

        return $directory;
    }
916533
public function getTemporaryDirectory()
    {
        $temp = Config::get('concrete.filesystem.temp_directory');
        if ($temp && @is_dir($temp)) {
            return $temp;
        }

        if (!is_dir(DIR_FILES_UPLOADED_STANDARD . '/tmp')) {
            @mkdir(DIR_FILES_UPLOADED_STANDARD . '/tmp', Config::get('concrete.filesystem.permissions.directory'));
            @chmod(DIR_FILES_UPLOADED_STANDARD . '/tmp', Config::get('concrete.filesystem.permissions.directory'));
            @touch(DIR_FILES_UPLOADED_STANDARD . '/tmp/index.html');
        }

        if (is_dir(DIR_FILES_UPLOADED_STANDARD . '/tmp') && is_writable(DIR_FILES_UPLOADED_STANDARD . '/tmp')) {
            return DIR_FILES_UPLOADED_STANDARD . '/tmp';
        }

        if ($temp = getenv('TMP')) {
            return str_replace(DIRECTORY_SEPARATOR, '/', $temp);
        }
        if ($temp = getenv('TEMP')) {
            return str_replace(DIRECTORY_SEPARATOR, '/', $temp);
        }
        if ($temp = getenv('TMPDIR')) {
            return str_replace(DIRECTORY_SEPARATOR, '/', $temp);
        }

        $temp = @tempnam(__FILE__, '');
        if (file_exists($temp)) {
            unlink($temp);

            return str_replace(DIRECTORY_SEPARATOR, '/', dirname($temp));
        }
    }
1309290
public function getDirectory() : ?string 
    {
        if ( ! $this->hasDirectory()) {
            $this->setDirectory($this->getDefaultDirectory());
        }
        return $this->directory;
    }
856589
protected static function getTempDir()
    {
        $name = tempnam(sys_get_temp_dir(), 'tmp');
        unlink($name);
        mkdir($name, 0777, true);
        return $name;
    }
672340
private function getTmpPath(): string
    {
        $tmpDir = sys_get_temp_dir();
        if (!empty($this->prefix)) {
            $tmpDir .= '/' . $this->prefix;
        }
        $tmpDir .= '/' . $this->id;
        return $tmpDir;
    }
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;
    }
1232352
protected function prepareAndGetDirectory()
    {
        if (! $this->filesystem->isDirectory($this->directory)) {
            $this->filesystem->makeDirectory($this->directory, 0755, true);
        }

        return $this->directory;
    }
663743
public static function createTempDir($prefix) {
    $newTempDir = tempnam(sys_get_temp_dir(), $prefix) . '.d';
    mkdir($newTempDir, 0755, TRUE);

    return $newTempDir;
  }
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;
    }
1240479
public function save()
    {
        // Grab the directory and create it if needed
        $info = pathinfo($this->fname);
        $dir  = $info['dirname'];

        if (!is_dir($dir)) {
            // dir doesn't exist, make it
          mkdir($dir, 0777, true);
        }


        return file_put_contents($this->fname, json_encode($this->data));
    }
295795
public function getDirectory()
    {
        $dir = clone $this;
        $dir->path = str_replace(DIRECTORY_SEPARATOR, '/', dirname($this->path));
        if (!$dir->path) $dir->path = '/';

        return $dir;
    }
758489
public static File createTempDir() throws IllegalStateException
   {
      File baseDir = getTempDirectory();
      try
      {
         return Files.createTempDirectory(baseDir.toPath(), "tmpdir").toFile();
      }
      catch (IOException e)
      {
         throw new IllegalStateException("Error while creating temporary directory", e);
      }
   }
612399
public function getFullPath()
    {
        return rtrim(
            '' == $this->path ? $this->name : $this->path . DIRECTORY_SEPARATOR . $this->name,
            DIRECTORY_SEPARATOR
        );
    }
782164
function temp_dir()
    {
        $dir = '';
        if (function_exists('sys_get_temp_dir')) {
            $dir = sys_get_temp_dir();
        }
        if (!$dir && $tmp = getenv('TMP')) {
            $dir = $tmp;
        }
        if (!$dir && $tmp = getenv('TEMP')) {
            $dir = $tmp;
        }
        if (!$dir && $tmp = getenv('TMPDIR')) {
            $dir = $tmp;
        }
        if (!$dir) {
            $tmp = tempnam(__FILE__, '');
            if (file_exists($tmp)) {
                unlink($tmp);
                $dir = dirname($tmp);
            }
        }
        if (!$dir) {
            return '';
        }
        $slash = (strtolower(substr(PHP_OS, 0, 3)) === 'win' ? '\\' : '/');
        if (substr($dir, -1) != $slash) {
            $dir = $dir . $slash;
        }

        return $dir;
    }
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;
    }
1307903
protected function getTmpDir() {
		if (!self::$tmpDir) {
			$tmpDir = $this->getAppRoot() . self::$globalOptions['tmpDir'];
			if (!\MvcCore\Application::GetInstance()->GetCompiled()) {
				if (!is_dir($tmpDir)) mkdir($tmpDir, 0777, TRUE);
				if (!is_writable($tmpDir)) {
					try {
						@chmod($tmpDir, 0777);
					} catch (\Exception $e) {
						$selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__;
						throw new \Exception('['.$selfClass.'] ' . $e->getMessage());
					}
				}
			}
			self::$tmpDir = $tmpDir;
		}
		return self::$tmpDir;
	}