Returns random temporary file name
@param  string $dir Directory
@param  string $prefix Prefix
@return string         Path
973486
public static function genRndTempnam($dir = null, $prefix = 'php')
    {
        if (!$dir) {
            $dir = sys_get_temp_dir();
        }

        static $n = 0;

        return $dir . '/' . $prefix . str_shuffle(
            md5(
                str_shuffle(
                    microtime(true) . chr(mt_rand(0, 0xFF))
                    . Daemon::$process->getPid() . chr(mt_rand(0, 0xFF))
                    . (++$n) . mt_rand(0, mt_getrandmax())
                )
            )
        );
    }
847376
public static function get_filetree($dir, $file_prefix = "/*") {
		$tree = array ();
		foreach ( glob ( $dir . $file_prefix ) as $single ) {
			if (is_dir ( $single )) {
				$tree = array_merge ( $tree, self::get_filetree ( $single ) );
			} else {
				$tree [] = $single;
			}
		}
		return $tree;
	}
454837
public function dir()
    {
        $this->_name = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid($this->_prefix);
        if (!mkdir($this->_name)) {
            throw new \Exception('Cannot create temporary directory');
        }
        return $this;
    }
245255
public function generateMapDir($dir)
    {
        $filepath = $this->getCachePath($dir);
        if (Generator::dump($dir, $filepath) == false) {
            throw new Exception("Error writing cache to " . $filepath);
        }
    }
1154642
protected function getCachePath($dir)
    {
        $filepath = $this->getCacheName($dir);

        return $this->getAutoLoader()->getCachePath() . $filepath;
    }
743564
static function getFileName( $prefix = 'Language', $code, $suffix = '.php' ) {
		// Protect against path traversal
		if ( !Language::isValidCode( $code )
			|| strcspn( $code, ":/\\\000" ) !== strlen( $code ) )
		{
			throw new MWException( "Invalid language code \"$code\"" );
		}

		return $prefix . str_replace( '-', '_', ucfirst( $code ) ) . $suffix;
	}
285804
public static function tempfile($prefix)
    {
        global $settings;
        $folder = '/tmp';
        if (isset($settings['temporary_folder'])) {
            $folder = $settings['temporary_folder'];
        }
        return tempnam($folder, $prefix);
    }
466069
public function makeTempFile( $prefix = '', $content = '' ) {
		$fileName = $prefix . $this->getRandomHexString();
		$filePath = $this->path . DIRECTORY_SEPARATOR . $fileName;
		$ok = file_put_contents( $filePath, $content );
		if ( $ok === false ) {
			throw new GpgLibException( "Could not create temporary file at $filePath" );
		}
		return $filePath;
	}
681751
def _use_last_dir_name(self, path, prefix=''):
        
        matching_dirs = (
            dir_name
            for dir_name in reversed(os.listdir(path))
            if os.path.isdir(os.path.join(path, dir_name)) and
            dir_name.startswith(prefix)
        )
        return next(matching_dirs, None) or ''
473147
static function getDir($dir = '.', $ext = NULL) {

		if($dir != '') {
			$dir = rtrim($dir, '/').'/';
		}
		try {
			$i = new \DirectoryIterator($dir);
		} catch (\Exception $e) {
			return false;
		}

		$files = array();

		foreach($i as $file) {
			$fn = $file->getFileName();
			if(!$file->isDot() && $file->isFile() && substr($fn, 0, 1) !== '.') {
				if(!isset($ext) || preg_match("~$ext\$~", $fn)) {
					$files[] = $fn;
				}
			}
		}

		return $files;
	}
617469
private function getRandomGif($dir)
    {
        $imageIndex = mt_rand(0, \count($this->gifs[$dir]) - 1);

        return $this->gifs[$dir][$imageIndex];
    }
1306692
public static function tempFile(/*string*/ $prefix = '') {
    $prefix = @trim($prefix);
    if('' === $prefix) {
      $prefix = time() . '-' . rand(11111, 99999);
    }
    $prefix .= '.';
    $tempPath = tempnam(sys_get_temp_dir(), $prefix);
    return $tempPath;
  }
553755
def create_temp_file_name(suffix, prefix=None, dir=None, directory=None):
    
    if dir is not None:
        warnings.warn(
            "The dir argument is deprecated.\n" +
            "Please use the directory argument instead.", DeprecationWarning)
        # Deprecated since 1.9.0, will be removed in 2.0.0
        directory = dir

    if not prefix:
        prefix = tempfile.gettempprefix()
    fd, name = tempfile.mkstemp(suffix=suffix, prefix=prefix, dir=directory)
    file_obj = os.fdopen(fd)
    file_obj.close()
    return name
983661
public function registerPrefix($prefix, $directory)
    {
        $prefix = rtrim($prefix, self::PREFIX_SEPARATOR). self::PREFIX_SEPARATOR;
        $this->prefixes[$prefix] = $this->normalizeDirectory($directory);
        return $this;
    }
1116608
public function getTemporaryFile($directory = null)
    {
        if ($directory === null) {
            $directory = $this->getTemporaryDirectory();
        }

        $name = str_replace('.', '', uniqid('buffer', true));
        $path = $directory.'/'.$name;

        touch($path);

        return $path;
    }
978687
public static function prefix($prefix = null)
	{
		if(null !== $prefix)
		{
			self::$prefix = $prefix;
		}
		return self::$prefix;
	}
590121
public function get_file_cache($key,$prefix=''){
        $option = array(
            'type'=>'File',
            'prefix'=>$prefix,
            'path'=>CACHE_PATH,
        );
        $cache = \think\Cache::connect($option);
        return $cache->get($key,[]);
    }