void Close( void )
-
Closes the file.
BOOL Flush( void )
-
Synchronizes the contents of memory with the contents
of the physical disk file.
BOOL FromHandle( HANDLE file_handle,
UINT open_flags = CFile64::modeRead,
ULONGLONG begining_at = 0,
DWORD number_of_bytes_to_map,
void * desired_address = NULL )-
Pretty much the same as Open() except you pass
in the handle to the file to use in mapping. This makes it much
faster when you have to remap different sections of the same file.
If you pass the handle to the file, you can skip the overhead that
Open() must incur by going to the filesystem to
actually open the file you're going to map. FromHandle() doesn't
have that problem.
DWORD GetAttributes( void ) const
-
Retrieves the attributes used in the wrapped CreateFile() API. This value is used in
the sixth parameter to CreateFile(). This method is called by the
Open method. The default value is FILE_ATTRIBUTE_NORMAL.
ULONGLONG GetFileLength( void ) const
-
Returns the length of the Open()'d file.
Yes, this returns a 64-bit length.
void GetFilename( CString& filename ) const
-
Retrieves the name of the file that is mapped. If
filename
is empty, no file has been opened.
DWORD GetLength( void ) const
-
Returns the number of bytes that were mapped.
void * GetPointer( void ) const
-
Returns the pointer to the mapped bytes. If this method
returns NULL, it means there is no file mapped.
HANDLE GetTemplateFile( void ) const
-
Retrieves the handle to the file that will be used as a template in the
Open method. This handle is used as the seventh parameter
to the wrapped CreateFile() API.
BOOL Open( LPCTSTR filename,
UINT open_flags = CFile64::modeRead,
ULONGLONG begining_at = 0,
DWORD number_of_bytes_to_map,
void * desired_address = NULL )-
This method is patterend after the Open() method in the
MFC
CFile64 class. In it's simplest form, you pass a name of a file
and it will open that file in read only mode. This is great
for parsing data files.
You don't have to worry about the
beginning_at value
be a special value (like in the call to the MapViewOfFile()
API).
The other parameters have these meanings:
open_flags - May be one of the following values:
CFile64::modeRead - Open the file for read only
CFile64::modeWrite - Open the file for read/write
CFile64::modeReadWrite - Open the file for read/write
beginning_at - The offset into the file of
where to start mapping.
number_of_bytes_to_map - The number of bytes
to map. If this parameter is zero, the default is to compute
the number of bytes that were mapped. You can call GetLength()
to find out how many bytes were mapped.
desired_address - This is where you ask
nicely that the address returned by GetPointer() be this
value. Win32 may or may not be able to map the bytes in the file
to desired_address. Never count on desired_address
actually being used.
void SetAttributes( DWORD attributes )
-
Sets the attributes used in the wrapped CreateFile() API. This value is used in
the sixth parameter to CreateFile().
void SetTemplateFile( HANDLE template_file_handle )
-
Sets the handle to the file that will be used as a template in the
Open method. This handle is used as the seventh parameter
to the wrapped CreateFile() API.