File

This subclass is for unbuffered file system streams.

Constructors

this
this()
Undocumented in source.
this
this(HANDLE hFile, FileMode mode)
Undocumented in source.
this
this(string filename, FileMode mode)

Create the stream with no open file, an open file in read mode, or an open file with explicit file mode. mode, if given, is a combination of FileMode.In (indicating a file that can be read) and FileMode.Out (indicating a file that can be written). Opening a file for reading that doesn't exist will error. Opening a file for writing that doesn't exist will create the file. The FileMode.OutNew mode will open the file for writing and reset the length to zero. The FileMode.Append mode will open the file for writing and move the file position to the end of the file.

Destructor

~this
~this()
Undocumented in source.

Members

Functions

close
void close()

Close the current file if it is open; otherwise it does nothing.

create
void create(string filename)
void create(string filename, FileMode mode)

Create a file for writing.

handle
HANDLE handle()
Undocumented in source. Be warned that the author may not have intended to support it.
open
void open(string filename, FileMode mode)

Open a file for the stream, in an identical manner to the constructors. If an error occurs an OpenException is thrown.

readBlock
size_t readBlock(void* buffer, size_t size)
Undocumented in source. Be warned that the author may not have intended to support it.
seek
ulong seek(long offset, SeekPos rel)
Undocumented in source. Be warned that the author may not have intended to support it.
writeBlock
size_t writeBlock(void* buffer, size_t size)
Undocumented in source. Be warned that the author may not have intended to support it.

Properties

available
size_t available [@property getter]

For a seekable file returns the difference of the size and position and otherwise returns 0.

size
ulong size [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.

Inherited Members

From Stream

readable
bool readable;

Indicates whether this stream can be read from.

writeable
bool writeable;

Indicates whether this stream can be written to.

seekable
bool seekable;

Indicates whether this stream can be sought within.

isopen
bool isopen;

Indicates whether this stream is open.

readEOF
bool readEOF;

Indicates whether this stream is at eof after the last read attempt.

prevCr
bool prevCr;

For a non-seekable stream indicates that the last readLine or readLineW ended on a '\r' character.

readBlock
size_t readBlock(void* buffer, size_t size)

Read up to size bytes into the buffer and return the number of bytes actually read. A return value of 0 indicates end-of-file.

readExact
void readExact(void* buffer, size_t size)
Undocumented in source. Be warned that the author may not have intended to support it.
read
size_t read(ubyte[] buffer)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(byte x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(ubyte x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(short x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(ushort x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(int x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(uint x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(long x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(ulong x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(float x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(double x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(real x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(ifloat x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(idouble x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(ireal x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(cfloat x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(cdouble x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(creal x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(char x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(wchar x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(dchar x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(char[] s)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(wchar[] s)
Undocumented in source. Be warned that the author may not have intended to support it.
readLine
char[] readLine()
Undocumented in source. Be warned that the author may not have intended to support it.
readLine
char[] readLine(char[] result)
Undocumented in source. Be warned that the author may not have intended to support it.
readLineW
wchar[] readLineW()
Undocumented in source. Be warned that the author may not have intended to support it.
readLineW
wchar[] readLineW(wchar[] result)
Undocumented in source. Be warned that the author may not have intended to support it.
opApply
int opApply(int delegate(ref char[] line) dg)
Undocumented in source. Be warned that the author may not have intended to support it.
opApply
int opApply(int delegate(ref ulong n, ref char[] line) dg)
Undocumented in source. Be warned that the author may not have intended to support it.
opApply
int opApply(int delegate(ref wchar[] line) dg)
Undocumented in source. Be warned that the author may not have intended to support it.
opApply
int opApply(int delegate(ref ulong n, ref wchar[] line) dg)
Undocumented in source. Be warned that the author may not have intended to support it.
readString
char[] readString(size_t length)
Undocumented in source. Be warned that the author may not have intended to support it.
readStringW
wchar[] readStringW(size_t length)
Undocumented in source. Be warned that the author may not have intended to support it.
ungetAvailable
bool ungetAvailable()
Undocumented in source. Be warned that the author may not have intended to support it.
getc
char getc()
Undocumented in source. Be warned that the author may not have intended to support it.
getcw
wchar getcw()
Undocumented in source. Be warned that the author may not have intended to support it.
ungetc
char ungetc(char c)
Undocumented in source. Be warned that the author may not have intended to support it.
ungetcw
wchar ungetcw(wchar c)
Undocumented in source. Be warned that the author may not have intended to support it.
vreadf
int vreadf(TypeInfo[] arguments, va_list args)
Undocumented in source. Be warned that the author may not have intended to support it.
readf
int readf(...)
Undocumented in source. Be warned that the author may not have intended to support it.
available
size_t available [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
writeBlock
size_t writeBlock(void* buffer, size_t size)

Write up to size bytes from buffer in the stream, returning the actual number of bytes that were written.

writeExact
void writeExact(void* buffer, size_t size)
Undocumented in source. Be warned that the author may not have intended to support it.
write
size_t write(const(ubyte)[] buffer)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(byte x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(ubyte x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(short x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(ushort x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(int x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(uint x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(long x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(ulong x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(float x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(double x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(real x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(ifloat x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(idouble x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(ireal x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(cfloat x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(cdouble x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(creal x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(char x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(wchar x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(dchar x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(const(char)[] s)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(const(wchar)[] s)
Undocumented in source. Be warned that the author may not have intended to support it.
writeLine
void writeLine(const(char)[] s)
Undocumented in source. Be warned that the author may not have intended to support it.
writeLineW
void writeLineW(const(wchar)[] s)
Undocumented in source. Be warned that the author may not have intended to support it.
writeString
void writeString(const(char)[] s)
Undocumented in source. Be warned that the author may not have intended to support it.
writeStringW
void writeStringW(const(wchar)[] s)
Undocumented in source. Be warned that the author may not have intended to support it.
vprintf
size_t vprintf(const(char)[] format, va_list args)
Undocumented in source. Be warned that the author may not have intended to support it.
printf
size_t printf(const(char)[] format, ...)
Undocumented in source. Be warned that the author may not have intended to support it.
writef
OutputStream writef(...)
Undocumented in source. Be warned that the author may not have intended to support it.
writefln
OutputStream writefln(...)
Undocumented in source. Be warned that the author may not have intended to support it.
writefx
OutputStream writefx(TypeInfo[] arguments, va_list argptr, int newline)
Undocumented in source. Be warned that the author may not have intended to support it.
copyFrom
void copyFrom(Stream s)

Copies all data from s into this stream. This may throw ReadException or WriteException on failure. This restores the file position of s so that it is unchanged.

copyFrom
void copyFrom(Stream s, ulong count)

Copy a specified number of bytes from the given stream into this one. This may throw ReadException or WriteException on failure. Unlike the previous form, this doesn't restore the file position of s.

seek
ulong seek(long offset, SeekPos whence)

Change the current position of the stream. whence is either SeekPos.Set, in which case the offset is an absolute index from the beginning of the stream, SeekPos.Current, in which case the offset is a delta from the current position, or SeekPos.End, in which case the offset is a delta from the end of the stream (negative or zero offsets only make sense in that case). This returns the new file position.

seekSet
ulong seekSet(long offset)

Aliases for their normal seek counterparts.

seekCur
ulong seekCur(long offset)
Undocumented in source. Be warned that the author may not have intended to support it.
seekEnd
ulong seekEnd(long offset)
Undocumented in source. Be warned that the author may not have intended to support it.
position
ulong position [@property setter]

Sets file position. Equivalent to calling seek(pos, SeekPos.Set).

position
ulong position [@property getter]

Returns current file position. Equivalent to seek(0, SeekPos.Current).

size
ulong size [@property getter]

Retrieve the size of the stream in bytes. The stream must be seekable or a SeekException is thrown.

eof
bool eof [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
isOpen
bool isOpen [@property getter]
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.
close
void close()
Undocumented in source. Be warned that the author may not have intended to support it.
toString
string toString()

Read the entire stream and return it as a string. If the stream is not seekable the contents from the current position to eof is read and returned.

toHash
size_t toHash()

Get a hash of the stream by reading each byte and using it in a CRC-32 checksum.

assertReadable
void assertReadable()
Undocumented in source. Be warned that the author may not have intended to support it.
assertWriteable
void assertWriteable()
Undocumented in source. Be warned that the author may not have intended to support it.
assertSeekable
void assertSeekable()
Undocumented in source. Be warned that the author may not have intended to support it.

Meta