www.digitalmars.com Home | Search | D | Comments
Last update Mon Aug 22 2005
D
Language
Phobos
Comparisons


object

std
 std.base64
 std.boxer
 std.compiler
 std.conv
 std.ctype
 std.date
 std.file
 std.format
 std.gc
 std.intrinsic
 std.math
 std.md5
 std.mmfile
 std.openrj
 std.outbuffer
 std.path
 std.process
 std.random
 std.recls
 std.regexp
 std.socket
 std.socketstream
 std.stdint
 std.stdio
 std.cstream
 std.stream
 std.string
 std.system
 std.thread
 std.uri
 std.utf
 std.zip
 std.zlib

std.windows

std.linux

std.c
 std.c.stdio

std.c.windows

std.c.linux

std.mmfile

Read and write memory mapped files.
class MmFile
MmFile objects control the memory mapped file resource. Any errors detected by the MmFile objects will throw an instance of std.file.FileException.

enum Mode
The mode the memory mapped file is opened with:

Read
read existing file
ReadWriteNew
delete existing file, write new file
ReadWrite
read/write existing file, create if not existing
ReadCopyOnWrite
read/write existing file, copy on write

this(char[] filename);
Open memory mapped file filename for reading. File is closed when the object instance is deleted.

this(char[] filename, Mode mode, size_t size, void* address);
Open memory mapped file filename in mode. File is closed when the object instance is deleted.
filename gives the name of the file. If null, an anonymous file mapping is created.
mode gives the access mode defined above.
size gives the size of the file. If 0, it is taken to be the size of the existing file.
address gives the preferred address to map the file to, allthough the system is not required to honor it. If null, the system selects the most convenient address.

~this()
Flushes pending output and closes the memory mapped file.

void flush()
Flushes pending output.

Mode mode()
Read-only property returning the file mode.

size_t length()
Gives size in bytes of the memory mapped file.

Operator overloads

void[] opSlice()
Returns entire file contents as an array.

void[] opSlice(size_t i1, size_t i2)
Returns slice of file contents as an array.

ubyte opIndex(size_t i)
Returns byte at index i in file.

ubyte opIndex(size_t i, ubyte value)
Returns sets byte at index i in file to value.

Notes

  • Won't work with files larger than the address space.

Feedback and Comments

Add feedback and comments regarding this page.
Copyright © 1999-2005 by Digital Mars, All Rights Reserved