ΒΆinline std::error_code openFileForWrite(
    const llvm::Twine& Name,
    int& ResultFD,
    llvm::sys::fs::CreationDisposition Disp =
        CD_CreateAlways,
    llvm::sys::fs::OpenFlags Flags = OF_None,
    unsigned int Mode = 438)

Description

Opens the file with the given name in a write-only or read-write mode, returning its open file descriptor. If the file does not exist, it is created.

The caller is responsible for closing the file descriptor once they are finished with it.

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

Parameters

const llvm::Twine& Name
The path of the file to open, relative or absolute.
int& ResultFD
If the file could be opened successfully, its descriptor is stored in this location. Otherwise, this is set to -1.
llvm::sys::fs::CreationDisposition Disp = CD_CreateAlways
llvm::sys::fs::OpenFlags Flags = OF_None
Additional flags used to determine whether the file should be opened in, for example, read-write or in write-only mode.
unsigned int Mode = 438
The access permissions of the file, represented in octal.

Returns

errc::success if \a Name has been opened, otherwise a platform-specific error_code.