FileStream

This is a Stream that writes/reads directly from, and to a file.

It uses std.stdio.File internally.

Other than exceptions, this class does not allocate any GC memory (though the same cannot be said for File, I haven't checked yet).

Constructors

this
this(Mode mode, char[] file)

Opens the specified file.

this
this(Mode mode, File file, DisposeOnDtor doDtor)

Wraps around an existing File.

Destructor

~this
~this()
Undocumented in source.

Members

Aliases

DisposeOnDtor
alias DisposeOnDtor = Flag!"doDtor"
Undocumented in source.

Enums

Mode
enum Mode

Describes how the file should be opened.

Functions

dispose
void dispose()
Undocumented in source. Be warned that the author may not have intended to support it.
flush
void flush()
Undocumented in source. Be warned that the author may not have intended to support it.
readToBuffer
ubyte[] readToBuffer(ubyte[] buffer)
Undocumented in source. Be warned that the author may not have intended to support it.
seek
void seek(SeekFrom from, ptrdiff_t amount)
Undocumented in source. Be warned that the author may not have intended to support it.
write
const(ubyte[]) write(ubyte[] data)
Undocumented in source. Be warned that the author may not have intended to support it.

Properties

isDisposed
bool isDisposed [@property getter]

For FileStreams, this function will return true if the underlying File has been closed.

length
size_t length [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
length
size_t length [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
position
size_t position [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
position
size_t position [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
readTimeout
Duration readTimeout [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
readTimeout
Duration readTimeout [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
writeTimeout
Duration writeTimeout [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
writeTimeout
Duration writeTimeout [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.

Examples

import std.exception : assertThrown;

auto mode   = FileStream.Mode.ReadWriteCreate | FileStream.Mode.Truncate | FileStream.Mode.Binary;
auto stream = new FileStream(mode, "tests/fs2.bin");

stream.length = 200;
assert(stream.length == 200);

assertThrown!StreamException(stream.position = 201);

Meta