bool eraseFromDisk(bool destroy_contents = false,
std::string *Err = 0) const;
-
- /// MapInFilePages - This is a low level system API to map in the file
- /// that is currently opened as FD into the current processes' address
- /// space for read only access. This function may return null on failure
- /// or if the system cannot provide the following constraints:
- /// 1) The pages must be valid after the FD is closed, until
- /// UnMapFilePages is called.
- /// 2) Any padding after the end of the file must be zero filled, if
- /// present.
- /// 3) The pages must be contiguous.
- ///
- /// This API is not intended for general use, clients should use
- /// MemoryBuffer::getFile instead.
- static const char *MapInFilePages(int FD, size_t FileSize,
- off_t Offset);
-
- /// UnMapFilePages - Free pages mapped into the current process by
- /// MapInFilePages.
- ///
- /// This API is not intended for general use, clients should use
- /// MemoryBuffer::getFile instead.
- static void UnMapFilePages(const char *Base, size_t FileSize);
-
/// @}
/// @name Data
/// @{
#endif
return false;
}
-
-const char *Path::MapInFilePages(int FD, size_t FileSize, off_t Offset) {
- int Flags = MAP_PRIVATE;
-#ifdef MAP_FILE
- Flags |= MAP_FILE;
-#endif
- void *BasePtr = ::mmap(0, FileSize, PROT_READ, Flags, FD, Offset);
- if (BasePtr == MAP_FAILED)
- return 0;
- return (const char*)BasePtr;
-}
-
-void Path::UnMapFilePages(const char *BasePtr, size_t FileSize) {
- const void *Addr = static_cast<const void *>(BasePtr);
- ::munmap(const_cast<void *>(Addr), FileSize);
-}
-
} // end llvm namespace
CloseHandle(h);
return false;
}
-
-/// MapInFilePages - Not yet implemented on win32.
-const char *Path::MapInFilePages(int FD, size_t FileSize, off_t Offset) {
- return 0;
-}
-
-/// MapInFilePages - Not yet implemented on win32.
-void Path::UnMapFilePages(const char *Base, size_t FileSize) {
- assert(0 && "NOT IMPLEMENTED");
-}
-
}
}