coastline 0.0.4
Loading...
Searching...
No Matches
CFile Class Reference

Windows file wrapper with automatic closure and unchecked byte writes. More...

#include <mfc.h>

Inheritance diagram for CFile:
Collaboration diagram for CFile:

Public Types

enum  OpenFlags : UINT { modeWrite = 0x0001 , modeCreate = 0x1000 , typeBinary = 0x8000 }
 Bit flags accepted by Open(); combinations select access and creation behaviour. More...

Public Member Functions

 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.
Public Member Functions inherited from CObject
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.

Detailed Description

Windows file wrapper with automatic closure and unchecked byte writes.

Member Enumeration Documentation

◆ 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.

Constructor & Destructor Documentation

◆ CFile()

CFile::CFile ( )

Initialise a wrapper without an open file.

◆ ~CFile()

CFile::~CFile ( )
override

Close a file successfully opened through this wrapper.

Member Function Documentation

◆ 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
fileNameThe non-null, terminated ANSI path.
openFlagsThe OpenFlags combination.
errorThe 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
bufferReadable storage of at least count bytes for an open writable file.
countThe 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: