Class File
Represents a file.

All Subcl's AsyncFile, SyncFile
Defined in <seqan/file.h>
Signature template <[typename TSpec]> class File<TSpec>;

Template Parameters

TSpec Specializing type. Default: Async<>.

Interface Function Overview

Interface Functions Detail

bool asyncReadAt(file, memPtr, count, fileOfs, request);

Asynchronously loads records from a specific position in a file.

Parameters

file The File object to read from.
memPtr A pointer to the first destination record in memory.
count The amount of records to be read.
fileOfs The absolute file position in bytes measured from the beginning.
request Reference to a structure that will be associated with this asynchronous request. Type: AsyncRequest.

Returns

bool true on success, false on failure.

bool asyncWriteAt(file, memPtr, count, fileOfs, request);

Asynchronously writes records to a specific position in a file.

Parameters

file The File object.
memPtr A pointer to the first source record in memory.
count The amount of records to be written.
fileOfs The absolute file position in bytes measured form the beginning.
request Reference to a structure that will be associated with this asynchronous request.

Returns

bool true on succcess, false on failure.

bool cancel(file, request);

Cancels an asynchronous request.

Parameters

file The File to cancel the request for.
request Reference to an AsyncRequest object. Type: AsyncRequest.

Returns

bool true on success, false on failure.

bool close(file);

Close a file.

Parameters

file The File object to close.

Returns

bool true on success, false on failure.

void flush(file);

Waits for all open requests to complete.

Parameters

file The File object to flush.

bool open(file, fileName, openMode);

Opens a file, stream, or persistent string.

Parameters

file The File to open.
fileName A char const * string containing the file name.
openMode Combination of flags defining how the file should be opened. See FileOpenMode for more details. Type: int. If you omit the OPEN_APPEND flag in write mode, the file will be cleared when opened. Default: OPEN_RDWR | OPEN_CREATE | OPEN_APPEND.

Returns

bool true on success, false on failure.

bool openTemp(file);

Opens a temporary file.

Parameters

file The File object to open the temporary file.

Returns

bool true on success, false on failure.
bool true on success false on failure.

Remarks

After closing this file will be deleted automatically. The openmode (see open) is OPEN_RDWR | OPEN_CREATE.

bool read(file, memPtr, count);

Loads record from a file.

Parameters

file The File object.
memPtr A pointer to the first destination record in memory.
count The amount of records to be read.

Returns

bool true on success, false on failure.

Remarks

The records are read from the position pointed to by the current file pointer (see seek).

bool readAt(file, memPtr, count, fileOfs);

Loads records from a specific position in a file.

Parameters

file The File object to read from.
memPtr A pointer to the first destination record in memory.
count The amount of records to be read.
fileOfs The absolute file position in bytes measured from the beginning.

Returns

bool true on success and false on failure.

void resize(file, newLength);

A file object.

Parameters

file The File object to resize.
newLength The file size in bytes to resize to in bytes.

void rewind(file);

Sets the current file pointer to the beginning of a file.

Parameters

file The file to reset the file pointer of.

TPosition seek(file, fileOfs[, origin]);

Changes the current file pointer.

Parameters

file The File object to seek in.
fileOfs A file offset measured in bytes relative to origin.
origin Selects the origin from where to calculate the new position. One of SEEK_BEGIN, SEEK_CURRENT, and SEEK_END (origin is beginning, current pointer, end of the file). Default: SEEK_BEGIN.

Returns

TPosition The new file position measured in bytes from the beginning.

bool setEof(file);

Sets the file end to the current pointer.

Parameters

file The File object to set the end of.

Returns

bool true on success, false on failure.

TSize size(file);

Return the file size.

Parameters

file The File object to query for its size.

Returns

TSize The file size measured in bytes.

TPosition tell(file);

Gets the current file pointer.

Parameters

file The File object to query for the current position.

Returns

TPosition The current position in the file.

bool waitFor(request[, timeout]);

Waits for an asychronous request to complete.

Parameters

request Reference to an AsyncRequest.
timeout A timeout value in milliseconds. A value of 0 can be used to test for completion without waiting. Default: 0.

Returns

bool true on completion, false on timeout.

Remarks

waitfor block sand suspends the calling thread process until request is completed or after timeout milliseconds.

bool write(file, memPtr, count);

Saves records to a file.

Parameters

file The File object.
memPtr Pointer to the source for the data to write.
count The number of records to write.

Returns

bool true on success, false on failure.

Remarks

The records are written at the position pointed to by th ecurrent file pointer (see seek).

bool writeAt(file, memPtr, count, fileOfs);

Saves records to a specific position in a file.

Parameters

file The File object to write to.
memPtr Pointer to the memory to write.
count The amount of records to be written.
fileOfs The absolute file position in bytes measured from the beginning.

Returns

bool true on success, false on failure.