llvm::sys::fs::openFileForWrite

Opens the file for write, creating it if it does not exist.

Synopsis

Declared in <llvm/Support/FileSystem.h>

std::error_code
openFileForWrite(
    Twine const& Name,
    int& ResultFD,
    CreationDisposition Disp = CD_CreateAlways,
    OpenFlags Flags = OF_None,
    unsigned int Mode = 0666);

Description

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

Return Value

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

Parameters

NameDescription
NameThe path of the file to open, relative or absolute.
ResultFDIf the file could be opened successfully, its descriptor is stored in this location. Otherwise, this is set to -1.
DispValue specifying the existing-file behavior.
FlagsAdditional flags used to determine whether the file should be opened in, for example, read-write or in write-only mode.
ModeThe access permissions of the file, represented in octal.