Deno.maketempfile
makeTempFile
-
makeTempFile(options?: MakeTempOptions): Promise<string>
-
在默认文件夹(另见
Deno.dir("temp")
)中创建一个临时文件,如果指定了dir
, 则在指定的dir
中创建。 其他可选的参数包括分别给文件名添加前缀的prefix
和给文件名添加后缀的sufix
。Creates a new temporary file 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 file.
多个程序同时调用该函数将会创建不同的文件。当不再需要该临时文件时,调用者应该主动删除该文件。
Multiple programs calling this function simultaneously will create different files. It is the caller’s responsibility to remove the file when no longer needed.
const tmpFileName0 = await Deno.makeTempFile(); // e.g. /tmp/419e0bf2 const tmpFileName1 = await Deno.makeTempFile({ prefix: 'my_temp' }); //e.g. /tmp/my_temp754d3098
需要
allow-write
权限。Requires
allow-write
permission.
参数
- ##### Optional options: [MakeTempOptions](interfaces/deno.maketempoptions.html)