Deno.maketempdir
makeTempDir
-
makeTempDir(options?: MakeTempOptions): Promise<string>
-
在默认文件夹(另见
Deno.dir("temp")
)中创建一个临时文件夹,如果指定了dir
, 则在指定的dir
中创建。 其他可选的参数包括分别给文件夹名添加前缀的prefix
和给文件夹名添加后缀的sufix
。Creates a new temporary directory in the default directory for temporary files (see also
Deno.dir("temp")
), unlessdir
is specified. Other optional options include prefixing and suffixing the directory name withprefix
andsuffix
respectively.返回新建文件夹的完整路径。
This call resolves to the full path to the newly created directory.
多个程序同时调用该函数将会创建不同的文件夹。当不再需要该临时文件夹时,调用者应该主动删除该文件夹。
Multiple programs calling this function simultaneously will create different directories. It is the caller’s responsibility to remove the directory when no longer needed.
const tempDirName0 = await Deno.makeTempDir(); // e.g. /tmp/2894ea76 const tempDirName1 = await Deno.makeTempDir({ prefix: 'my_temp' }); // e.g. /tmp/my_temp339c944d
需要
allow-write
权限。Requires
allow-write
permission.
参数
- ##### Optional options: [MakeTempOptions](interfaces/deno.maketempoptions.html)