Skip to main content

create-temp-file

function

babashka.fs/create-temp-file

(create-temp-file [] [{:keys [:dir :prefix :suffix :posix-file-permissions], :as opts}])
Creates an empty file using [Files/createTempFile](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/Files.html#createTempFile(java.nio.file.Path,java.lang.String,java.lang.String,java.nio.file.attribute.FileAttribute...)). This function does not set up any automatic deletion of the files it creates. Create the file in a [[with-temp-dir]] for that functionality. Options: * `:dir`: Directory in which to create the new file. Defaults to default system temp dir (e.g. `/tmp`); see [[temp-dir]]. Must already exist. * `:prefix`: Provided as a hint to the process that generates the name of the new file. In most cases, this will be the beginning of the new file name. Defaults to a random (v4) UUID. * `:suffix`: Provided as a hint to the process that generates the name of the new file. In most cases, this will be the end of the new file name. Defaults to a random (v4) UUID. * `:posix-file-permissions`: The new file will be created with these permissions, given as a String as described in [[str->posix]]. If not specified, uses the file system default permissions for new files. Affected by [umask](/README.md#umask). * :warning: `:path` **[DEPRECATED]** Previous name for `:dir`, kept for backwards compatibility. If both `:path` and `:dir` are given (don't do that!), `:dir` is used. Examples: * `(create-temp-file)` * `(create-temp-file {:posix-file-permissions "rw-------"})` * `(create-temp-file {:dir (path (cwd) "_workdir") :prefix "process-1-" :suffix "-queue"})`

No examples yet. Be the first to add one!