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.

Constructors

this
this(VFSFile file, Flag!"append" append)
Undocumented in source.

Destructor

~this
~this()
Undocumented in source.

Postblit

this(this)
this(this)
Undocumented in source.

Members

Functions

opAssign
void opAssign(VFSFileOutput rhs)
Undocumented in source. Be warned that the author may not have intended to support it.
seek
void seek(long offset, Seek origin)

Set file position to offset bytes from specified origin.

write
void write(void[] data)

Write data to file starting at current file position.

Examples

VFSFile file; //initialized somewhere before

auto output = file.output;
with(output)
{
    //Write to the file:
    write(cast(const void[])"The answer is ??");

    //Change the last two characters in the file:
    seek(-2, Seek.End);
    write(cast(const void[])"42");
}
//Appending:
//When appending to the file, every write writes to the end of file
//regardless of any calls to seek(), and sets the file position
//to end of file. This
//(This is to stay in line with the C standard so we can use C functions directly)
auto output = file.output(Yes.append);
with(output)
{
    //Append to the file:
    write(cast(const void[])"The answer is ??");

    //This will NOT change the last 2 characters: it will append anyway:
    seek(-2, Seek.End);
    write(cast(const void[])"42");
}

Meta