ΒΆstd::error_code createUniqueFile(
    const llvm::Twine& Model,
    int& ResultFD,
    SmallVectorImpl<char>& ResultPath,
    unsigned int Mode = all_read | all_write)

Description

Create a uniquely named file. Generates a unique path suitable for a temporary file and then opens it as a file. The name is based on \a Model with '%' replaced by a random char in [0-9a-f]. If \a Model is not an absolute path, the temporary file will be created in the current directory. Example: clang-%%-%%-%%-%%-%%.s => clang-a0-b1-c2-d3-e4.s This is an atomic operation. Either the file is created and opened, or the file system is left untouched. The intended use is for files that are to be kept, possibly after renaming them. For example, when running 'clang -c foo.o', the file can be first created as foo-abc123.o and then renamed.

Declared at: llvm/include/llvm/Support/FileSystem.h:827

Parameters

const llvm::Twine& Model
Name to base unique path off of.
int& ResultFD
Set to the opened file's file descriptor.
SmallVectorImpl<char>& ResultPath
Set to the opened file's absolute path.
unsigned int Mode = all_read | all_write

Returns

errc::success if Result{FD,Path} have been successfully set, otherwise a platform-specific error_code.