ΒΆstd::error_code openFileForRead(
    const llvm::Twine& Name,
    int& ResultFD,
    llvm::sys::fs::OpenFlags Flags = OF_None,
    SmallVectorImpl<char>* RealPath = nullptr)

Description

Opens the file with the given name in a read-only mode, returning its open file descriptor.

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

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

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::OpenFlags Flags = OF_None
SmallVectorImpl<char>* RealPath = nullptr
If nonnull, extra work is done to determine the real path of the opened file, and that path is stored in this location.

Returns

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