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 | ||||
Constructors | ||||
MappedFile (const Path &path, int options=READ_ACCESS) | ||||
~MappedFile () | ||||
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 () | |||
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 33 of file MappedFile.h.
|
Definition at line 37 of file MappedFile.h. |
|
Construct a MappedFile to the
Definition at line 50 of file MappedFile.h. |
|
Destruct a MappedFile and release all memory associated with it.
Definition at line 55 of file MappedFile.h. |
|
Obtain the base pointer to the memory mapped file.
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 75 of file MappedFile.h. |
|
Obtain the base pointer to the memory mapped file.
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 85 of file MappedFile.h. |
|
Definition at line 124 of file MappedFile.h. |
|
Determine if a MappedFile is currently mapped
This function determines if the file is currently mapped or not.
Definition at line 65 of file MappedFile.h. |
|
Map the file into memory. The mapped file is put into memory.
Definition at line 78 of file Unix/MappedFile.cpp. References EXEC_ACCESS, llvm::sys::Path::get(), llvm::GetPageSize(), isMapped(), SHARED_MAPPING, and ThrowErrno(). Referenced by llvm::Archive::Archive(), size(), llvm::Archive::writeMember(), and llvm::Archive::writeToDisk(). |
|
Returns the mapped file's path as a sys::Path
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 93 of file MappedFile.h. |
|
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.
Definition at line 116 of file Unix/MappedFile.cpp. References llvm::GetPageSize(), map(), and unmap(). |
|
This function returns the number of bytes in the file.
Definition at line 111 of file Unix/MappedFile.cpp. Referenced by llvm::Archive::checkSignature(), llvm::Archive::findModuleDefiningSymbol(), llvm::Archive::findModulesDefiningSymbols(), llvm::Archive::loadArchive(), llvm::Archive::loadSymbolTable(), llvm::Archive::writeMember(), and llvm::Archive::writeToDisk(). |
|
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. Definition at line 69 of file Unix/MappedFile.cpp. References isMapped(). Referenced by size(), llvm::Archive::writeMember(), llvm::Archive::writeToDisk(), and llvm::Archive::~Archive(). |