std.mmfile
Read and write memory mapped files.
Memory mapped files are a mechanism in operating systems that allows file access through virtual memory. After opening a file with MmFile, the contents can be read from or written to with standard slice / pointer operations. Changes to the memory are automatically reflected in the underlying file.
Memory mapping can increase I/O performance of large files, compared to buffered read / write operations from std.file and std.stdio. However, I/O errors are not handled as safely: when for example the disk that the file is on gets removed, reading from it may result in a segfault.
Copyright
Copyright The D Language Foundation 2004 - 2009.
class MmFile
Types 1
classMmFile
MmFile objects control the memory mapped file resource.
Methods
void flush()void[] opSlice()Returns entire file contents as an array.void[] opSlice(ulong i1, ulong i2)Returns slice of file contents as an array.ubyte opIndex(ulong i)Returns byte at index i in file.ubyte opIndexAssign(ubyte value, ulong i)Sets and returns byte at index i in file to value.private
int mapped(ulong i)private
void unmap()private
void map(ulong start, size_t len)private
void ensureMapped(ulong i)private
void ensureMapped(ulong i, ulong j)Constructors
this(string filename)Open memory mapped file filename for reading. File is closed when the object instance is deleted. Throws: - On POSIX, ErrnoException. - On Windows, WindowsException.Destructors
~thisFlushes pending output and closes the memory mapped file.Nested Templates
ModeThe mode the memory mapped file is opened with.