Class
FileRepresents a 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
-
bool asyncReadAt(file, memPtr, count, fileOfs, request);
Asynchronously loads records from a specific position in a file. -
bool asyncWriteAt(file, memPtr, count, fileOfs, request);
Asynchronously writes records to a specific position in a file. -
bool cancel(file, request);
Cancels an asynchronous request. -
bool close(file);
Close a file. -
void flush(file);
Waits for all open requests to complete. -
TSize length(file);
Return the file size. -
bool open(file, fileName, openMode);
Opens a file, stream, or persistent string. -
bool openTemp(file);
Opens a temporary file. -
bool read(file, memPtr, count);
Loads record from a file. -
bool readAt(file, memPtr, count, fileOfs);
Loads records from a specific position in a file. -
void resize(file, newLength);
A file object. -
void rewind(file);
Sets the current file pointer to the beginning of a file. -
TPosition seek(file, fileOfs[, origin]);
Changes the current file pointer. -
bool setEof(file);
Sets the file end to the current pointer. -
TPosition tell(file);
Gets the current file pointer. -
bool waitFor(request[, timeout]);
Waits for an asynchronous request to complete. -
bool write(file, memPtr, count);
Saves records to a file. -
bool writeAt(file, memPtr, count, fileOfs);
Saves records to a specific position in a file.
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. |
---|
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
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 success, false on failure. |
---|
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
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. |
---|
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
bool close(file);
Close a file.
Parameters
file
|
The File object to close. |
---|
Returns
bool |
true on success, false on failure. |
---|
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
void flush(file);
Waits for all open requests to complete.
Parameters
file
|
The File object to flush. |
---|
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
TSize length(file);
Return the file size.
Parameters
file
|
The File object to query for its size. |
---|
Returns
TSize |
The file size measured in bytes. |
---|
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
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. |
---|
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
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.
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
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).
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
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. |
---|
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
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. |
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
void rewind(file);
Sets the current file pointer to the beginning of a file.
Parameters
file
|
The file to reset the file pointer of. |
---|
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
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. |
---|
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
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. |
---|
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
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. |
---|
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
bool waitFor(request[, timeout]);
Waits for an asynchronous 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.
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
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 the current file pointer (see seek).
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
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. |
---|
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.