temp +linux +x86_64

The temp module provides support for creating temporary directories and files.

Index

Functions

fn dir() str;
fn file(io::mode, fs::mode...) (io::file | fs::error);
fn named(*fs::fs, str, io::mode, fs::mode...) ((io::file, str) | fs::error);

Functions

fn dir[link]

fn dir() str;

Creates a temporary directory. This function only guarantees that the directory will have a unique name and be placed in the system temp directory, but not that it will be removed automatically; the caller must remove it when they're done using it via os::rmdir or os::rmdirall.

The return value is statically allocated and will be overwritten on subsequent calls.

fn file[link]

fn file(iomode: io::mode, mode: fs::mode...) (io::file | fs::error);

Creates an unnamed temporary file. The file may or may not have a name; not all systems support the creation of temporary inodes which are not linked to any directory. If it is necessary to create a real file, it will be removed when the stream is closed.

The I/O mode must be either io::mode::WRITE or io::mode::RDWR.

Only one variadic argument may be provided, if at all, to specify the mode of the new file. The default is 0o644.

fn named[link]

fn named(
	fs: *fs::fs,
	path: str,
	iomode: io::mode,
	mode: fs::mode...
) ((io::file, str) | fs::error);

Creates a named temporary file in the given directory of the given filesystem. The caller is responsible for closing and removing the file when they're done with it. The name is statically allocated, and will be overwritten on subsequent calls.

The I/O mode must be either io::mode::WRITE or io::mode::RDWR.

Only one variadic argument may be provided, if at all, to specify the mode of the new file. The default is 0o644.