Windows file wrapper with automatic closure and unchecked byte writes.
More...
#include <mfc.h>
|
| | CFile () |
| | Initialise a wrapper without an open file.
|
| | ~CFile () override |
| | Close a file successfully opened through this wrapper.
|
| virtual BOOL | Open (LPCSTR fileName, UINT openFlags, CFileException *error=nullptr) |
| | Open a Windows file with shared read and write access.
|
| virtual void | Write (const void *buffer, UINT count) |
| | Attempt a synchronous write without reporting failure or a partial write.
|
| virtual void | Close () |
| | Close the current file if open and reset the wrapper, discarding closure errors.
|
| virtual CRuntimeClass * | GetRuntimeClass () const |
| virtual | ~CObject () |
| | The base destructor does not perform additional cleanup.
|
| virtual void | Serialize (CArchive &archive) |
| | Do not serialise archive data.
|
| virtual void | AssertValid () const |
| | Do not validate object state.
|
| virtual void | Dump (CDumpContext &context) const |
| | Do not emit diagnostic output.
|
Windows file wrapper with automatic closure and unchecked byte writes.
◆ OpenFlags
Bit flags accepted by Open(); combinations select access and creation behaviour.
| Enumerator |
|---|
| modeWrite | Request write access rather than the default read access.
|
| modeCreate | Create a new file or truncate an existing file.
|
| typeBinary | Binary-mode compatibility flag; Windows byte operations require no conversion.
|
◆ CFile()
Initialise a wrapper without an open file.
◆ ~CFile()
Close a file successfully opened through this wrapper.
◆ Open()
| virtual BOOL CFile::Open |
( |
LPCSTR | fileName, |
|
|
UINT | openFlags, |
|
|
CFileException * | error = nullptr ) |
|
virtual |
Open a Windows file with shared read and write access.
The wrapper must not already have an open file; its previous handle is not closed here.
- Parameters
-
| fileName | The non-null, terminated ANSI path. |
| openFlags | The OpenFlags combination. |
| error | The unused optional error object; failure does not populate it. |
- Returns
- TRUE on success, with automatic closure enabled; FALSE on failure.
◆ Write()
| virtual void CFile::Write |
( |
const void * | buffer, |
|
|
UINT | count ) |
|
virtual |
Attempt a synchronous write without reporting failure or a partial write.
- Parameters
-
| buffer | Readable storage of at least count bytes for an open writable file. |
| count | The byte count to write. |
◆ Close()
| virtual void CFile::Close |
( |
| ) |
|
|
virtual |
Close the current file if open and reset the wrapper, discarding closure errors.
The documentation for this class was generated from the following file: