vl-filename-mktemp

(vl-filename-mktemp [pattern] [folder [extension]])

The vl-filename-mktemp returns a unique file name for a temporary file.

Arguments

pattern specifies a file name pattern used for generating a temporary file name (as text string).

If a pattern is not specified or the argument is nil, the function uses "$VL~~nnn", where nnn represents a number in the text string (e.g. 001).

If pattern exceeds five characters, only the first five characters are used.

folder specifies the folder for the temporary file (as text string).

If a folder is not specified or the argument is nil, it chooses a folder in the following order:

extension specifies an extension for the temporary file to generate (as text string).

If an extension is not specified or the argument is nil, the function uses the extension part of pattern (which can be an empty string).

Return Value

The function returns a text string with a unique temporary file name. The temporary file name is formed by appending a three-digit number to the base of the name thus making it unique.

Examples

: (vl-filename-mktemp "temp.tmp")

"C:\\Users\\admin\\AppData\\Local\\Temp\\temp002.tmp"

: (vl-filename-mktemp)

"C:\\Users\\admin\\AppData\\Local\\Temp\\$VL~~001""

: (vl-filename-mktemp "c:\\myproject\\temp.tmp")

"C:\\myproject\\temp003.tmp"

: (vl-filename-mktemp "temp" "c:\\myproject")

"C:\\myproject\\temp004"

: (vl-filename-mktemp "temp" "c:\\myproject" ".tmp")

"C:\\myproject\\temp005.tmp"

: (vl-filename-mktemp "temp.tmp" "c:\\myproject")

"C:\\myproject\\temp006.tmp"