Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

OW32::CFile Class Reference

Thin wrapper around the Win32 file API. More...

#include <File.h>

List of all members.

Public Member Functions

 CFile ()
 Default constructor.
 CFile (HANDLE hFile)
 Constructor taking a file handle to encapsulate.
HANDLE Detach ()
 Detach the encapsulated file handle.
void Attach (HANDLE h)
 Attach the given file handle to the class.
 operator HANDLE () const
 Extractor returning the encapsulated handle.
HANDLE * operator & ()
 Extractor returning the address of the encapsulated handle.
HANDLE operator= (HANDLE h)
 Assign a new handle and take ownership of it.
BOOL CreateA (LPCSTR lpFileName, DWORD dwDesiredAccess=0, DWORD dwShareMode=0, LPSECURITY_ATTRIBUTES lpSecurityAttributes=NULL, DWORD dwCreationDisposition=0, DWORD dwFlagsAndAttributes=0, HANDLE hTemplateFile=NULL)
 As for the Win32 CreateFileA function.
BOOL CreateW (LPCWSTR lpFileName, DWORD dwDesiredAccess=0, DWORD dwShareMode=0, LPSECURITY_ATTRIBUTES lpSecurityAttributes=NULL, DWORD dwCreationDisposition=0, DWORD dwFlagsAndAttributes=0, HANDLE hTemplateFile=NULL)
 As for the Win32 CreateFileW function.
BOOL Create (LPCTSTR lpFileName, DWORD dwDesiredAccess=0, DWORD dwShareMode=0, LPSECURITY_ATTRIBUTES lpSecurityAttributes=NULL, DWORD dwCreationDisposition=0, DWORD dwFlagsAndAttributes=0, HANDLE hTemplateFile=NULL)
 As for the Win32 CreateFile function.
void Close ()
 Close any open file.
BOOL CreateAlwaysA (LPCSTR lpFileName, DWORD dwDesiredAccess=GENERIC_WRITE|GENERIC_READ, DWORD dwShareMode=0, LPSECURITY_ATTRIBUTES lpSecurityAttributes=NULL, DWORD dwFlagsAndAttributes=0, HANDLE hTemplateFile=NULL)
 As for Create, but a creation disposition of CREATE_ALWAYS is used.
BOOL CreateAlwaysW (LPCWSTR lpFileName, DWORD dwDesiredAccess=GENERIC_WRITE|GENERIC_READ, DWORD dwShareMode=0, LPSECURITY_ATTRIBUTES lpSecurityAttributes=NULL, DWORD dwFlagsAndAttributes=0, HANDLE hTemplateFile=NULL)
 As for Create, but a creation disposition of CREATE_ALWAYS is used.
BOOL CreateAlways (LPCTSTR lpFileName, DWORD dwDesiredAccess=GENERIC_WRITE|GENERIC_READ, DWORD dwShareMode=0, LPSECURITY_ATTRIBUTES lpSecurityAttributes=NULL, DWORD dwFlagsAndAttributes=0, HANDLE hTemplateFile=NULL)
 As for Create, but a creation disposition of CREATE_ALWAYS is used.
BOOL OpenExistingA (LPCSTR lpFileName, DWORD dwDesiredAccess=GENERIC_WRITE|GENERIC_READ, DWORD dwShareMode=0, LPSECURITY_ATTRIBUTES lpSecurityAttributes=NULL, DWORD dwFlagsAndAttributes=0, HANDLE hTemplateFile=NULL)
 As for Create, but a creation disposition of OPEN_EXISTING is used.
BOOL OpenExistingW (LPCWSTR lpFileName, DWORD dwDesiredAccess=GENERIC_WRITE|GENERIC_READ, DWORD dwShareMode=0, LPSECURITY_ATTRIBUTES lpSecurityAttributes=NULL, DWORD dwFlagsAndAttributes=0, HANDLE hTemplateFile=NULL)
 As for Create, but a creation disposition of OPEN_EXISTING is used.
BOOL OpenExisting (LPCTSTR lpFileName, DWORD dwDesiredAccess=GENERIC_WRITE|GENERIC_READ, DWORD dwShareMode=0, LPSECURITY_ATTRIBUTES lpSecurityAttributes=NULL, DWORD dwFlagsAndAttributes=0, HANDLE hTemplateFile=NULL)
 As for Create, but a creation disposition of OPEN_EXISTING is used.
BOOL OpenAlwaysA (LPCSTR lpFileName, DWORD dwDesiredAccess=GENERIC_WRITE|GENERIC_READ, DWORD dwShareMode=0, LPSECURITY_ATTRIBUTES lpSecurityAttributes=NULL, DWORD dwFlagsAndAttributes=0, HANDLE hTemplateFile=NULL)
 As for Create, but a creation disposition of OPEN_ALWAYS is used.
BOOL OpenAlwaysW (LPCWSTR lpFileName, DWORD dwDesiredAccess=GENERIC_WRITE|GENERIC_READ, DWORD dwShareMode=0, LPSECURITY_ATTRIBUTES lpSecurityAttributes=NULL, DWORD dwFlagsAndAttributes=0, HANDLE hTemplateFile=NULL)
 As for Create, but a creation disposition of OPEN_ALWAYS is used.
BOOL OpenAlways (LPCTSTR lpFileName, DWORD dwDesiredAccess=GENERIC_WRITE|GENERIC_READ, DWORD dwShareMode=0, LPSECURITY_ATTRIBUTES lpSecurityAttributes=NULL, DWORD dwFlagsAndAttributes=0, HANDLE hTemplateFile=NULL)
 As for Create, but a creation disposition of OPEN_ALWAYS is used.
BOOL Read (LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead=NULL, LPOVERLAPPED lpOverlapped=NULL)
 Read from a file or device.
BOOL Write (LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten=NULL, LPOVERLAPPED lpOverlapped=NULL)
 Write to a file or device.
BOOL GetSize (PULARGE_INTEGER pSize)
 Get the size of a file.
BOOL SetPointer (const LARGE_INTEGER &liDistanceToMove, DWORD dwMoveMethod=FILE_BEGIN, PLARGE_INTEGER lpNewFilePointer=NULL)
 Reposition the file pointer.
BOOL SetPointer (__int64 i64DistanceToMove, DWORD dwMoveMethod=FILE_BEGIN, PLARGE_INTEGER lpNewFilePointer=NULL)
 Reposition the file pointer.
BOOL SetEnd ()
 Resize a file.
BOOL IsOpen ()
 Determine whether the class encapsulates an open file.
BOOL GetInformation (LPBY_HANDLE_FILE_INFORMATION lpFileInformation)
 Retrieve file information (as for GetFileInformationByHandle).
BOOL FlushBuffers ()
 Flush file buffers to disk.
BOOL SetTime (const FILETIME *lpCreationTime, const FILETIME *lpLastAccessTime, const FILETIME *lpLastWriteTime)
 Set the date and time that the file was created, accessed or modified.


Detailed Description

Thin wrapper around the Win32 file API.

Effectively this class wraps a file or device handle and most of the standard API methods for manipulating them. It takes care of the CloseHandle call in the destructor so resources are automatically cleaned up.


Member Function Documentation

void OW32::CFile::Attach HANDLE  h  )  [inline]
 

Attach the given file handle to the class.

Any encapsulated file handle will be released.

void OW32::CFile::Close  )  [inline]
 

Close any open file.

BOOL OW32::CFile::Create LPCTSTR  lpFileName,
DWORD  dwDesiredAccess = 0,
DWORD  dwShareMode = 0,
LPSECURITY_ATTRIBUTES  lpSecurityAttributes = NULL,
DWORD  dwCreationDisposition = 0,
DWORD  dwFlagsAndAttributes = 0,
HANDLE  hTemplateFile = NULL
[inline]
 

As for the Win32 CreateFile function.

BOOL OW32::CFile::CreateA LPCSTR  lpFileName,
DWORD  dwDesiredAccess = 0,
DWORD  dwShareMode = 0,
LPSECURITY_ATTRIBUTES  lpSecurityAttributes = NULL,
DWORD  dwCreationDisposition = 0,
DWORD  dwFlagsAndAttributes = 0,
HANDLE  hTemplateFile = NULL
[inline]
 

As for the Win32 CreateFileA function.

BOOL OW32::CFile::CreateW LPCWSTR  lpFileName,
DWORD  dwDesiredAccess = 0,
DWORD  dwShareMode = 0,
LPSECURITY_ATTRIBUTES  lpSecurityAttributes = NULL,
DWORD  dwCreationDisposition = 0,
DWORD  dwFlagsAndAttributes = 0,
HANDLE  hTemplateFile = NULL
[inline]
 

As for the Win32 CreateFileW function.

HANDLE OW32::CFile::Detach  )  [inline]
 

Detach the encapsulated file handle.

Returns:
The encapsulated handle
The object will be returned to the state following a default construction and may be used again.

BOOL OW32::CFile::FlushBuffers  )  [inline]
 

Flush file buffers to disk.

Returns:
TRUE if successful, FALSE otherwise

BOOL OW32::CFile::GetInformation LPBY_HANDLE_FILE_INFORMATION  lpFileInformation  )  [inline]
 

Retrieve file information (as for GetFileInformationByHandle).

Returns:
TRUE if successful, FALSE otherwise

BOOL OW32::CFile::GetSize PULARGE_INTEGER  pSize  )  [inline]
 

Get the size of a file.

Works around issues and makes this look like GetSizeEx, but NT4 compatible.

BOOL OW32::CFile::IsOpen  )  [inline]
 

Determine whether the class encapsulates an open file.

Returns:
TRUE if there is an open file, FALSE otherwise.

BOOL OW32::CFile::Read LPVOID  lpBuffer,
DWORD  nNumberOfBytesToRead,
LPDWORD  lpNumberOfBytesRead = NULL,
LPOVERLAPPED  lpOverlapped = NULL
[inline]
 

Read from a file or device.

As for ReadFile.

BOOL OW32::CFile::SetEnd  )  [inline]
 

Resize a file.

As for SetEndOfFile.

BOOL OW32::CFile::SetPointer __int64  i64DistanceToMove,
DWORD  dwMoveMethod = FILE_BEGIN,
PLARGE_INTEGER  lpNewFilePointer = NULL
[inline]
 

Reposition the file pointer.

As for SetPointer above.

BOOL OW32::CFile::SetPointer const LARGE_INTEGER &  liDistanceToMove,
DWORD  dwMoveMethod = FILE_BEGIN,
PLARGE_INTEGER  lpNewFilePointer = NULL
[inline]
 

Reposition the file pointer.

As for SetPointerEx, but implemented in terms of SetFilePointer.

BOOL OW32::CFile::SetTime const FILETIME *  lpCreationTime,
const FILETIME *  lpLastAccessTime,
const FILETIME *  lpLastWriteTime
[inline]
 

Set the date and time that the file was created, accessed or modified.

Parameters:
lpCreationTime The creation time (NULL if not required)
lpLastAccessTime The last access time (NULL if not required)
lpLastWriteTime The last write time (NULL if not required)

BOOL OW32::CFile::Write LPCVOID  lpBuffer,
DWORD  nNumberOfBytesToWrite,
LPDWORD  lpNumberOfBytesWritten = NULL,
LPOVERLAPPED  lpOverlapped = NULL
[inline]
 

Write to a file or device.

As for WriteFile.


The documentation for this class was generated from the following file:
Generated on Sun Jun 5 01:29:24 2005 for OW32 by  doxygen 1.3.9.1