NCBI C++ ToolKit
|
Search Toolkit Book for CFileIO
Class for support low level input/output for files. More...
#include <corelib/ncbifile.hpp>
Public Types | |
enum | EAutoRemove { eDoNotRemove , eRemoveInClose , eRemoveASAP } |
Controls how temporary file is removed. More... | |
Public Types inherited from CFileIO_Base | |
enum | EOpenMode { eCreate , eCreateNew , eOpen , eOpenAlways , eTruncate } |
File open mode. More... | |
enum | EAccessMode { eRead , eWrite , eReadWrite } |
Which I/O operations permitted on the file. More... | |
enum | EShareMode { eShareRead , eShareWrite , eShare , eExclusive } |
Sharing mode for opened file. More... | |
enum | EPositionMoveMethod { eBegin , eCurrent , eEnd } |
Which starting point to use for the moves of the file pointer. More... | |
Public Member Functions | |
CFileIO (void) | |
Default constructor. More... | |
~CFileIO (void) | |
Destruct object closing system handle if necessary. More... | |
void | Open (const string &filename, EOpenMode open_mode, EAccessMode access_mode, EShareMode share_mode=eShare) |
Open file. More... | |
void | CreateTemporary (const string &dir, const string &prefix, EAutoRemove auto_remove=eRemoveInClose) |
Create temporary file in the specified directory. More... | |
void | Close (void) |
Close file. More... | |
size_t | Read (void *buf, size_t count) const |
Read file. More... | |
size_t | Write (const void *buf, size_t count) const |
Write file. More... | |
void | Flush (void) const |
Flush file buffers. More... | |
const string & | GetPathname (void) const |
Return file path and name as it was specified in the Open() method or created in CreateTemporary(). More... | |
TFileHandle | GetFileHandle (void) const |
Return system file handle associated with the file. More... | |
void | SetFileHandle (TFileHandle handle) |
Close previous handle if needed and use given handle for all I/O. More... | |
Uint8 | GetFilePos (void) const |
Get file position. More... | |
void | SetFilePos (Uint8 position) const |
Set file position from beginning of the file. More... | |
void | SetFilePos (Int8 offset, EPositionMoveMethod whence) const |
Set file position. More... | |
Uint8 | GetFileSize (void) const |
Get file size. More... | |
void | SetFileSize (Uint8 length, EPositionMoveMethod pos=eCurrent) const |
Set new size for the file. More... | |
void | SetAutoClose (bool auto_close=true) |
Define whether the open file handle needs to be closed in the destructor. More... | |
void | SetAutoRemove (EAutoRemove auto_remove=eRemoveInClose) |
Define whether the temporary file created by CreateTemporary() must be automatically removed in Close(). More... | |
Protected Attributes | |
string | m_Pathname |
File path and name. More... | |
TFileHandle | m_Handle |
System file handle. More... | |
bool | m_AutoClose |
Need to close file handle in destructor. More... | |
EAutoRemove | m_AutoRemove |
When (if ever) should the temporary file be removed. More... | |
Private Member Functions | |
CFileIO (const CFileIO &) | |
void | operator= (const CFileIO &) |
Class for support low level input/output for files.
Throw CFileException/CFileErrnoException on error.
Definition at line 3475 of file ncbifile.hpp.