Deno.maketempfilesync
makeTempFileSync
-
makeTempFileSync(options?: MakeTempOptions): string
-
以同步的方式在默认文件夹(另见
Deno.dir("temp")
)中创建一个临时文件,如果指定了dir
, 则在指定的dir
中创建。 其他可选的参数包括分别给文件名添加前缀的prefix
和给文件名添加后缀的sufix
。Synchronously 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.返回新建文件的完整路径。
The full path to the newly created file is returned.
多个程序同时调用该函数将会创建不同的文件。当不再需要该临时文件时,调用者应该主动删除该文件。
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 tempFileName0 = Deno.makeTempFileSync(); // e.g. /tmp/419e0bf2 const tempFileName1 = Deno.makeTempFileSync({ prefix: 'my_temp' }); //e.g. /tmp/my_temp754d3098
需要
allow-write
权限。Requires
allow-write
permission.
参数
- ##### Optional options: [MakeTempOptions](interfaces/deno.maketempoptions.html)