Authors: | Zahary Karadjov, Andreas Rumpf |
---|
This module provides support for memory mapped files (Posix's mmap) on the different operating systems.
Types
TMemFile = object {.pure.} mem*: pointer ## a pointer to the memory mapped file. The pointer ## can be used directly to change the contents of the ## file, if it was opened with write access. size*: int ## size of the memory mapped file when defined(windows): fHandle: int mapHandle: int else: handle: cint
- represents a memory mapped file
Procs
proc open(filename: string; mode: TFileMode = fmRead; mappedSize = - 1; offset = 0; newFileSize = - 1): TMemFile {.raises: [EOS], tags: [].}
- opens a memory mapped file. If this fails, EOS is raised. newFileSize can only be set if the file is not opened with fmRead access. mappedSize and offset can be used to map only a slice of the file.
proc close(f: var TMemFile) {.raises: [EOS], tags: [].}
- closes the memory mapped file f. All changes are written back to the file system, if f was opened with write access.