VFSFileOutput

Provides basic file output functionality - seeking and writing.

VFSFileOutput uses reference counting so that the file is closed when the last instance of VFSFileOutput provided by the file is destroyed.

Destructor

A destructor is present on this object, but not explicitly documented in the source.

Postblit

A postblit is present on this object, but not explicitly documented in the source.

Members

Functions

seek
void seek(long offset, Seek origin)

Set file position to offset bytes from specified origin.

write
void write(const void[] data)

Write data to file starting at current file position.

Examples

1 VFSFile file; //initialized somewhere before
2 
3 auto output = file.output;
4 with(output)
5 {
6    //Write to the file:
7    write(cast(const void[])"The answer is ??");
8 
9    //Change the last two characters in the file:
10    seek(-2, Seek.End);
11    write(cast(const void[])"42");
12 }
1 //Appending:
2 //When appending to the file, every write writes to the end of file
3 //regardless of any calls to seek(), and sets the file position
4 //to end of file. This
5 //(This is to stay in line with the C standard so we can use C functions directly)
6 auto output = file.output(Yes.append);
7 with(output)
8 {
9    //Append to the file:
10    write(cast(const void[])"The answer is ??");
11 
12    //This will NOT change the last 2 characters: it will append anyway:
13    seek(-2, Seek.End);
14    write(cast(const void[])"42");
15 }

Meta