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()Mode mode()Read-only property returning the file mode.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.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.this(string filename, Mode mode, ulong size, void * address,
size_t window = 0)Open memory mapped file filename in mode. File is closed when the object instance is deleted. Params: filename = name of the file. If null, an anonymous file mapping is created. mode = access mode ...Destructors
~thisFlushes pending output and closes the memory mapped file.Nested Templates
ModeThe mode the memory mapped file is opened with.