Obtain exclusive temporary file
@param  string $dir Directory
@param  string $prefix Prefix
@param  callable $cb Callback (File)
@return resource
330098
public static function tempnam($dir, $prefix, $cb)
    {
        $cb = CallbackWrapper::forceWrap($cb);
        if (!FileSystem::$supported) {
            FileSystem::open(tempnam($dir, $prefix), 'w!', $cb);
        }
        $tries = 0;
        static::tempnamHandler($dir, $prefix, $cb, $tries);
    }
1157703
public static function mkdir($path, $mode, $cb = null, $pri = EIO_PRI_DEFAULT)
    {
        $cb = CallbackWrapper::forceWrap($cb);
        if (!FileSystem::$supported) {
            $r = mkdir($path, $mode);
            if ($cb) {
                $cb($path, $r);
            }
            return $r;
        }
        return eio_mkdir($path, $mode, $pri, $cb, $path);
    }
488918
public function tmpFile($prefix = null)
    {
        $tmpPath = Env::get('RUNTIME_PATH') . 'file/';

        // 不存在则创建
        is_dir($tmpPath) || mkdir($tmpPath, 0755, true);

        $prefix || $prefix = 'tmp';
        return tempnam($tmpPath, $prefix);
    }
285804
public static function tempfile($prefix)
    {
        global $settings;
        $folder = '/tmp';
        if (isset($settings['temporary_folder'])) {
            $folder = $settings['temporary_folder'];
        }
        return tempnam($folder, $prefix);
    }
44550
public function sendfile($path, $cb, $pri = EIO_PRI_DEFAULT)
    {
        if ($this->state === self::STATE_FINISHED) {
            return false;
        }
        try {
            $this->header('Content-Type: ' . MIME::get($path));
        } catch (RequestHeadersAlreadySent $e) {
        }
        if ($this->upstream->checkSendfileCap()) {
            FileSystem::sendfile($this->upstream, $path, $cb, function ($file, $length, $handler) {
                try {
                    $this->header('Content-Length: ' . $length);
                } catch (RequestHeadersAlreadySent $e) {
                }
                $this->ensureSentHeaders();
                $this->upstream->onWriteOnce(function ($conn) use ($handler, $file) {
                    $handler($file);
                });
                return true;
            }, 0, null, $pri);
            return true;
        }
        $first = true;

        FileSystem::readfileChunked(
            $path,
            $cb,
            function ($file, $chunk) use (&$first) {
                // readed chunk
                if ($this->upstream->isFreed()) {
                    return false;
                }

                if ($first) {
                    try {
                        $this->header('Content-Length: ' . $file->stat['size']);
                    } catch (RequestHeadersAlreadySent $e) {
                    }
                    $first = false;
                }
                $this->out($chunk);
                return true;
            }
        );

        return true;
    }
1180537
public static function getPrivateFolder(string $extensionKey, string $prefix = 'EXT:'): string {
    return self::privateFolder($extensionKey, $prefix);
  }
7370
public static function wrap($cb, $timeout = null, $ctx = false)
    {
        if ($cb instanceof CallbackWrapper || ((Daemon::$context === null) && ($timeout === null))) {
            return $cb;
        }
        if ($cb === null) {
            return null;
        }
        return new static($cb, $timeout, $ctx !== false ? $ctx : Daemon::$context);
    }
397050
public function truncate($offset = 0, $cb = null, $pri = EIO_PRI_DEFAULT)
    {
        $cb = CallbackWrapper::forceWrap($cb);
        if (!$this->fd || $this->fd === -1) {
            if ($cb) {
                $cb($this, false);
            }
            return false;
        }
        if (!FileSystem::$supported) {
            $fp = fopen($this->path, 'r+');
            $r = $fp && ftruncate($fp, $offset);
            if ($cb) {
                $cb($this, $r);
            }
            return $r;
        }
        return eio_ftruncate($this->fd, $offset, $pri, $cb, $this);
    }
1124807
public static function add($prefix, $base_dir, $prepend = false) {

        //Normalize namespace prefix
        $prefix = trim($prefix, '\\') . '\\';

        //Normalize the base directory with a trailing separator
        $base_dir = rtrim($base_dir, DIRECTORY_SEPARATOR) . '/';

        //Initialize the namespace prefix array
        if(false === isset(static :: $psr0[$prefix])) {
            static :: $psr0[$prefix] = [];
        }

        //Retain the base directory for the namespace prefix
        if(true === $prepend) {
            array_unshift(static :: $psr0[$prefix], $base_dir);
        } else {
            array_push(static :: $psr0[$prefix], $base_dir);
        }
    }
919481
public function binDir($dir = '')
    {
        if (!empty($dir)) {
            $this->binary_dir = Config::setBinDirectory($dir);

            return $this;
        }
        elseif ($dir == C::DFT) {
            $this->binary_dir = Config::setBinDirectory(Config::getBinDirectory());
        }

        return Config::getBinDirectory();
    }
402129
public static function publicFolder(string $extensionKey, string $prefix = 'EXT:'): string {
    $resourcesFolder = self::resourcesFolder($extensionKey, $prefix);

    return "${resourcesFolder}/Public";
  }
663743
public static function createTempDir($prefix) {
    $newTempDir = tempnam(sys_get_temp_dir(), $prefix) . '.d';
    mkdir($newTempDir, 0755, TRUE);

    return $newTempDir;
  }
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,[]);
    }
530756
public static function createTempPath($prefix = 'php-')
    {
        $temp = tempnam(sys_get_temp_dir(), $prefix);

        if (false === $temp) {
            // @codeCoverageIgnoreStart
            throw new FileException(
                'A new temporary file could not be created.'
            );
        }
        // @codeCoverageIgnoreEnd

        return $temp;
    }
1002559
public static function temp($data = null, $path = 'tmp', $prefix = '~', $sulfix = '.tmp')
    {
        $fullpath = self::resolve($path);

        if ($fullpath === false) {
            return false;
        }

        $fullpath .= '/' . $prefix . base_convert(microtime(true), 10, 36);
        $fullpath .= rand(1, 1000) . $sulfix;

        if (is_file($fullpath) || self::put($fullpath, $data, LOCK_EX) === false) {
            return self::temp($data, $path, $prefix, $sulfix);
        }

        return $fullpath;
    }
990466
public static File createTempDir(String prefix, File directory) throws IOException {
        File tempFile = File.createTempFile(prefix, "", directory);
        if (!tempFile.delete())
            throw new IOException();
        if (!tempFile.mkdir())
            throw new IOException();
        return tempFile;
    }
311597
public function chdir($dir) {
		$this->connectIfNeeded();
		$this->handle->chdir($dir);
		$this->onFolderChanged(new Event(['sender' => $this, 'data' => $dir]));
		try {
			$cwd = $this->pwd();
		} catch (FtpException $ex) {
			$cwd = $dir;	
		}
		return $cwd;
	}