LLVM API Documentation
#include <MappedFile.h>
Collaboration diagram for llvm::sys::MappedFile:
Public Types | ||||
Types | ||||
enum | MappingOptions { READ_ACCESS = 0x0001, WRITE_ACCESS = 0x0002, EXEC_ACCESS = 0x0004, SHARED_MAPPING = 0x0008 } | |||
Public Member Functions | ||||
Accessors | ||||
bool | isMapped () const | |||
Determine if a MappedFile is currently mapped
| ||||
void * | base () const | |||
Obtain the base pointer to the memory mapped file.
| ||||
char * | charBase () const | |||
Obtain the base pointer to the memory mapped file.
| ||||
const sys::Path & | path () const | |||
Returns the mapped file's path as a sys::Path
| ||||
size_t | size () const | |||
Mutators | ||||
void | unmap () | |||
Remove the file mapping from memory. | ||||
void * | map () | |||
Map the file into memory. | ||||
void | size (size_t new_size) | |||
Set the size of the file and memory mapping. | ||||
void | close () |
This class provides an abstraction for a memory mapped file in the operating system's filesystem. It provides platform independent operations for mapping a file into memory for both read and write access. This class does not provide facilities for finding the file or operating on paths to files. The sys::Path class is used for that.
Definition at line 34 of file MappedFile.h.
READ_ACCESS | Map the file for reading. |
WRITE_ACCESS | Map the file for write access. |
EXEC_ACCESS | Map the file for execution access. |
SHARED_MAPPING | Map the file shared with other processes. |
Definition at line 38 of file MappedFile.h.
llvm::sys::MappedFile::MappedFile | ( | const Path & | path, | |
int | options = READ_ACCESS | |||
) | [inline] |
Construct a MappedFile to the path
in the operating system's file system with the mapping options
provided.
std::string | if an error occurs |
Definition at line 51 of file MappedFile.h.
llvm::sys::MappedFile::~MappedFile | ( | ) | [inline] |
Destruct a MappedFile and release all memory associated with it.
std::string | if an error occurs |
Definition at line 56 of file MappedFile.h.
llvm::sys::MappedFile::MappedFile | ( | const Path & | path, | |
int | options = READ_ACCESS | |||
) | [inline] |
Construct a MappedFile to the path
in the operating system's file system with the mapping options
provided.
std::string | if an error occurs |
Definition at line 51 of file MappedFile.h.
llvm::sys::MappedFile::~MappedFile | ( | ) | [inline] |
Destruct a MappedFile and release all memory associated with it.
std::string | if an error occurs |
Definition at line 56 of file MappedFile.h.
bool llvm::sys::MappedFile::isMapped | ( | ) | const [inline] |
Determine if a MappedFile is currently mapped
nothing. |
This function determines if the file is currently mapped or not.
Definition at line 66 of file MappedFile.h.
Referenced by llvm::SourceFile::getSourceLine().
void* llvm::sys::MappedFile::base | ( | ) | const [inline] |
Obtain the base pointer to the memory mapped file.
nothing. |
This function returns a void* pointer to the base address of the file mapping. This is the memory address of the first byte in the file. Note that although a non-const pointer is returned, the memory might not actually be writable, depending on the MappingOptions used when the MappedFile was opened.
Definition at line 76 of file MappedFile.h.
char* llvm::sys::MappedFile::charBase | ( | ) | const [inline] |
Obtain the base pointer to the memory mapped file.
nothing. |
This function returns a char* pointer to the base address of the file mapping. This is the memory address of the first byte in the file. Note that although a non-const pointer is returned, the memory might not actually be writable, depending on the MappingOptions used when the MappedFile was opened.
Definition at line 86 of file MappedFile.h.
Referenced by llvm::DiffFilesWithTolerance(), and llvm::SourceFile::getSourceLine().
const sys::Path& llvm::sys::MappedFile::path | ( | ) | const [inline] |
Returns the mapped file's path as a sys::Path
nothing. |
This function returns a reference to the sys::Path object kept by the MappedFile object. This contains the path to the file that is or will be mapped.
Definition at line 94 of file MappedFile.h.
size_t llvm::sys::MappedFile::size | ( | ) | const |
This function returns the number of bytes in the file.
std::string | if an error occurs |
Referenced by llvm::Archive::checkSignature(), llvm::Archive::findModuleDefiningSymbol(), llvm::Archive::findModulesDefiningSymbols(), llvm::SourceFile::getSourceLine(), llvm::Archive::loadArchive(), llvm::Archive::loadSymbolTable(), llvm::Archive::writeMember(), and llvm::Archive::writeToDisk().
void llvm::sys::MappedFile::unmap | ( | ) |
Remove the file mapping from memory.
The mapped file is removed from memory. If the file was mapped for write access, the memory contents will be automatically synchronized with the file's disk contents.
Referenced by llvm::SourceFile::~SourceFile().
void* llvm::sys::MappedFile::map | ( | ) |
Map the file into memory.
The mapped file is put into memory.
Referenced by llvm::Archive::Archive(), llvm::DiffFilesWithTolerance(), llvm::Archive::writeMember(), and llvm::Archive::writeToDisk().
void llvm::sys::MappedFile::size | ( | size_t | new_size | ) |
Set the size of the file and memory mapping.
This method causes the size of the file, and consequently the size of the mapping to be set. This is logically the same as unmap(), adjust size of the file, map(). Consequently, when calling this function, the caller should not rely on previous results of the map(), base(), or baseChar() members as they may point to invalid areas of memory after this call.
std::string | if an error occurs |
void llvm::sys::MappedFile::close | ( | ) | [inline] |
Definition at line 125 of file MappedFile.h.
Referenced by llvm::Archive::cleanUpMemory(), llvm::Archive::writeMember(), and llvm::Archive::writeToDisk().