#include <File.h>
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. |
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.
|
Attach the given file handle to the class. Any encapsulated file handle will be released. |
|
Close any open file.
|
|
As for the Win32 CreateFile function.
|
|
As for the Win32 CreateFileA function.
|
|
As for the Win32 CreateFileW function.
|
|
Detach the encapsulated file handle.
|
|
Flush file buffers to disk.
|
|
Retrieve file information (as for GetFileInformationByHandle).
|
|
Get the size of a file. Works around issues and makes this look like GetSizeEx, but NT4 compatible. |
|
Determine whether the class encapsulates an open file.
|
|
Read from a file or device. As for ReadFile. |
|
Resize a file. As for SetEndOfFile. |
|
Reposition the file pointer. As for SetPointer above. |
|
Reposition the file pointer. As for SetPointerEx, but implemented in terms of SetFilePointer. |
|
Set the date and time that the file was created, accessed or modified.
|
|
Write to a file or device. As for WriteFile. |