"L. Spiro Engine"
|
Cross-platform file functions. More...
#include <LSFFileLib.h>
Static Public Member Functions | |
static LSF_FILE LSE_CALL | OpenFile (const LSCHAR *_pcFile, LSF_OPEN_FILE _ofOpenType, LSBOOL _bOpenAlways) |
static LSBOOL LSE_CALL | CloseFile (LSF_FILE &_fFile) |
static LSBOOL LSE_CALL | ReadFile (LSF_FILE _fFile, LSVOID *_pvBuffer, LSUINTPTR _uiptrBytesToRead) |
static LSBOOL LSE_CALL | WriteFile (LSF_FILE _fFile, const LSVOID *_pvBuffer, LSUINTPTR _uiptrBytesToWrite) |
static LSBOOL LSE_CALL | SetFilePointer (LSF_FILE _fFile, LSINT64 _i64DistanceToMove, LSF_SEEK _sMoveMethod) |
static LSUINT64 LSE_CALL | GetFilePointer (LSF_FILE _fFile) |
static LSBOOL LSE_CALL | CreateFileMap (const LSCHAR *_pcFile, LSF_OPEN_FILE _ofOpenType, LSF_FILE_MAP &_fmMap) |
static LSBOOL LSE_CALL | CreateFileMap (const LSWCHAR_T *_pwcFile, LSF_OPEN_FILE _ofOpenType, LSF_FILE_MAP &_fmMap) |
static LSVOID LSE_CALL | DestroyFileMap (LSF_FILE_MAP &_fmMap) |
static LSVOID *LSE_CALL | Map (const LSF_FILE_MAP &_fmMap, LSUINT64 _ui64Offset, LSUINTPTR _uiptrLen) |
static LSVOID LSE_CALL | UnMap (const LSVOID *_pvAddr, LSUINTPTR _uiptrLen) |
static LSBOOL LSE_CALL | CanWriteToFileMap (const LSF_FILE_MAP &_fmMap) |
static LSUINT32 LSE_CALL | GetPageSize () |
static LSUINT64 LSE_CALL | GetFileSize (LSF_FILE _fFile) |
static LSUINT64 LSE_CALL | GetFileSize (const LSCHAR *_pcFile) |
static LSUINT64 LSE_CALL | GetFileSize (const LSWCHAR_T *_pwcFile) |
static LSBOOL LSE_CALL | Exists (const LSCHAR *_pcFile) |
static LSBOOL LSE_CALL | Exists (const LSWCHAR_T *_pwcFile) |
static LSCHAR *LSE_CALL | GetSelfDir (LSCHAR *_pcRet) |
static LSWCHAR_T *LSE_CALL | GetSelfDir (LSWCHAR_T *_pwcRet) |
static LSCHAR *LSE_CALL | ExpandPath (const LSCHAR *_pcPath, LSCHAR *_pcRet) |
static LSWCHAR_T *LSE_CALL | ExpandPath (const LSWCHAR_T *_pwcPath, LSWCHAR_T *_pwcRet) |
static LSCHAR *LSE_CALL | ExpandResourcePath (const LSCHAR *_pcPath, LSCHAR *_pcRet) |
static LSCHAR *LSE_CALL | NoExtension (LSCHAR *_pcPath) |
static LSWCHAR_T *LSE_CALL | NoExtension (LSWCHAR_T *_pwcPath) |
static LSCHAR *LSE_CALL | NoPath (LSCHAR *_pcPath) |
static LSWCHAR_T *LSE_CALL | NoPath (LSWCHAR_T *_pwcPath) |
static LSCHAR *LSE_CALL | NoFile (LSCHAR *_pcPath) |
static LSWCHAR_T *LSE_CALL | NoFile (LSWCHAR_T *_pwcPath) |
static LSINT32 LSE_CALL | Eof () |
static LSVOID LSE_CALL | SetResPath (const LSCHAR *_pcPath) |
static LSE_INLINE const LSCHAR *LSE_CALL | GetResPath () |
Static Protected Attributes | |
static LSCHAR | m_szResourcePath [LSF_MAX_PATH] |
static LSUINT32 | m_ui32ResPathLen |
Cross-platform file functions.
Class CFileLib Description: Handles opening, closing, reading from, and writing to files. Also allows getting information on files such as size.
static LSBOOL LSE_CALL lsf::CFileLib::CanWriteToFileMap | ( | const LSF_FILE_MAP & | _fmMap | ) | [static] |
Does the given file map provide write permissions?
_fmMap | The mapped file previously created with CreateFileMap(); |
static LSBOOL LSE_CALL lsf::CFileLib::CloseFile | ( | LSF_FILE & | _fFile | ) | [static] |
Close a file. Sets the file pointer to NULL automatically.
_fFile | Handle to the open file to close. This is set to an invalid handle after being closed. |
static LSBOOL LSE_CALL lsf::CFileLib::CreateFileMap | ( | const LSWCHAR_T * | _pwcFile, |
LSF_OPEN_FILE | _ofOpenType, | ||
LSF_FILE_MAP & | _fmMap | ||
) | [static] |
Create a file-mapping object. File must exist.
_pwcFile | The file to map. |
_ofOpenType | Flag determining how to open the file. Valid values are LSF_OF_READ, LSF_OF_WRITE, or both. |
_fmMap | Holds the returned file map upon success. If the function returns true, this structure must be passed to a call to DestroyFileMap() when no longer needed. |
static LSBOOL LSE_CALL lsf::CFileLib::CreateFileMap | ( | const LSCHAR * | _pcFile, |
LSF_OPEN_FILE | _ofOpenType, | ||
LSF_FILE_MAP & | _fmMap | ||
) | [static] |
Create a file-mapping object. File must exist.
_pcFile | The file to map. |
_ofOpenType | Flag determining how to open the file. Valid values are LSF_OF_READ, LSF_OF_WRITE, or both. |
_fmMap | Holds the returned file map upon success. If the function returns true, this structure must be passed to a call to DestroyFileMap() when no longer needed. |
static LSVOID LSE_CALL lsf::CFileLib::DestroyFileMap | ( | LSF_FILE_MAP & | _fmMap | ) | [static] |
Destroy a file map created with CreateFileMap(). Any regions not unmapped inside the file will become invalid. Use UnMap() on all mapped regions before calling this.
_fmMap | The file map to be destroyed. |
static LSINT32 LSE_CALL lsf::CFileLib::Eof | ( | ) | [static] |
Returns the system EOF (end-of-file) value. This is normally -1 but is not guaranteed to be so on every platform/compiler.
static LSBOOL LSE_CALL lsf::CFileLib::Exists | ( | const LSCHAR * | _pcFile | ) | [static] |
Does the given file exist? Files only!
_pcFile | Path to the file. |
static LSBOOL LSE_CALL lsf::CFileLib::Exists | ( | const LSWCHAR_T * | _pwcFile | ) | [static] |
Does the given file exist? Files only!
_pcFile | Path to the file. |
static LSCHAR* LSE_CALL lsf::CFileLib::ExpandPath | ( | const LSCHAR * | _pcPath, |
LSCHAR * | _pcRet | ||
) | [static] |
Fully expands the given path. The result is stored in _pcRet, which must be at least LSF_MAX_PATH characters long. Returns _pcRet or NULL on error.
_pcPath | Path to expand, in UTF-8 format. |
_pcRet | Buffer to receive the expanded path. Must be at least LSF_MAX_PATH characters long. |
static LSWCHAR_T* LSE_CALL lsf::CFileLib::ExpandPath | ( | const LSWCHAR_T * | _pwcPath, |
LSWCHAR_T * | _pwcRet | ||
) | [static] |
Fully expands the given path. The result is stored in _pwcRet, which must be at least LSF_MAX_PATH characters long. Returns _pwcRet or NULL on error.
_pwcPath | Path to expand. |
_pwcRet | Buffer to receive the expanded path. Must be at least LSF_MAX_PATH characters long. |
static LSCHAR* LSE_CALL lsf::CFileLib::ExpandResourcePath | ( | const LSCHAR * | _pcPath, |
LSCHAR * | _pcRet | ||
) | [static] |
Fully expands the given path, which is assumed to be relative to the resources directory. If the given path is not, an invalid path will be created.
_pcPath | Path to expand, in UTF-8 format. |
_pcRet | Buffer to receive the expanded path. Must be at least LSF_MAX_PATH characters long. |
static LSUINT64 LSE_CALL lsf::CFileLib::GetFilePointer | ( | LSF_FILE | _fFile | ) | [static] |
Returns the position of the file pointer.
_fFile | A handle to the file. |
static LSUINT64 LSE_CALL lsf::CFileLib::GetFileSize | ( | const LSWCHAR_T * | _pwcFile | ) | [static] |
Get the size of a file.
_pwcFile | Path to the file whose size is to be obtained. |
static LSUINT64 LSE_CALL lsf::CFileLib::GetFileSize | ( | LSF_FILE | _fFile | ) | [static] |
Get the size of an open file.
_fFile | Handle to the opened file whose size is to be obtained. |
static LSUINT64 LSE_CALL lsf::CFileLib::GetFileSize | ( | const LSCHAR * | _pcFile | ) | [static] |
Get the size of a file.
_pcFile | UTF-8 path to the file whose size is to be obtained. |
static LSUINT32 LSE_CALL lsf::CFileLib::GetPageSize | ( | ) | [static] |
Get the size of a page boundary for mapping files.
LSE_INLINE const LSCHAR *LSE_CALL lsf::CFileLib::GetResPath | ( | ) | [static] |
Gets the resource path.
static LSCHAR* LSE_CALL lsf::CFileLib::GetSelfDir | ( | LSCHAR * | _pcRet | ) | [static] |
Get the path to the directory in which this executable resides. Returns the string that was put into it. Must be at least LSF_MAX_PATH characters long. Returns NULL in the event of error. The returned string always ends with a backslash (or forward slash depending on the operating system).
_pcRet | Buffer to be filled with the path to this executable. |
static LSWCHAR_T* LSE_CALL lsf::CFileLib::GetSelfDir | ( | LSWCHAR_T * | _pwcRet | ) | [static] |
Get the path to the directory in which this executable resides. Returns the string that was put into it. Must be at least LSF_MAX_PATH characters long. Returns NULL in the event of error. The returned string always ends with a backslash (or forward slash depending on the operating system).
_pwcRet | Buffer to be filled with the path to this executable. |
static LSVOID* LSE_CALL lsf::CFileLib::Map | ( | const LSF_FILE_MAP & | _fmMap, |
LSUINT64 | _ui64Offset, | ||
LSUINTPTR | _uiptrLen | ||
) | [static] |
Map a region of a mapped file to memory. The mapped region must be unmapped with UnMap() when no longer needed.
_fmMap | The mapped file created with a previous call to CreateFileMap(). |
_ui64Offset | Offset into the file where to begin the mapping. Must be aligned on a system page boundary. |
_uiptrLen | Number of bytes to map starting at the given offset. |
static LSWCHAR_T* LSE_CALL lsf::CFileLib::NoExtension | ( | LSWCHAR_T * | _pwcPath | ) | [static] |
Remove the extension from a path. Returns the input string, which is modified in-place.
_pwcPath | On input, it holds the path whose extension is to be removed. On return, it holds the path without the removed extension. |
static LSCHAR* LSE_CALL lsf::CFileLib::NoExtension | ( | LSCHAR * | _pcPath | ) | [static] |
Remove the extension from a path. Returns the input string, which is modified in-place. The returned string is in UTF-8 format.
_pcPath | On input, it holds the path whose extension is to be removed. On return, it holds the path without the removed extension. |
static LSWCHAR_T* LSE_CALL lsf::CFileLib::NoFile | ( | LSWCHAR_T * | _pwcPath | ) | [static] |
Remove the file part of a path (leaves only the folder part). The return includes the terminating / or \. If there is no folder part to return, ./ is returned. Returns the input string, which is modified in-place.
_pwcPath | On input, it holds the string whose file part is to be removed. On return, it holds the string removed of its file. |
static LSCHAR* LSE_CALL lsf::CFileLib::NoFile | ( | LSCHAR * | _pcPath | ) | [static] |
Remove the file part of a path (leaves only the folder part). The return includes the terminating / or \. If there is no folder part to return, ./ is returned. Returns the input string, which is modified in-place.
_pcPath | On input, it holds the string whose file part is to be removed. On return, it holds the string removed of its file. |
static LSWCHAR_T* LSE_CALL lsf::CFileLib::NoPath | ( | LSWCHAR_T * | _pwcPath | ) | [static] |
Remove the path part from a path (leaves only the file part). Returns the input string, which is modified in-place.
_pwcPath | On input, it holds the string whose path part is to be removed. On return, it holds the string removed of its path. |
static LSCHAR* LSE_CALL lsf::CFileLib::NoPath | ( | LSCHAR * | _pcPath | ) | [static] |
Remove the path part from a path (leaves only the file part). Returns the input string, which is modified in-place. The returned string is in UTF-8 format.
_pcPath | On input, it holds the string whose path part is to be removed. On return, it holds the string removed of its path. |
static LSF_FILE LSE_CALL lsf::CFileLib::OpenFile | ( | const LSCHAR * | _pcFile, |
LSF_OPEN_FILE | _ofOpenType, | ||
LSBOOL | _bOpenAlways | ||
) | [static] |
Open a file. Returns NULL if failed.
_pcFile | Path to the file to open. Must be UTF-8. |
_ofOpenType | Flag determining how to open the file. Valid values are LSF_OF_READ, LSF_OF_WRITE, and LSF_OF_APPEND, and some combinations thereof. |
_bOpenAlways | If true, the file is opened even if it does not exist (it is created). |
static LSBOOL LSE_CALL lsf::CFileLib::ReadFile | ( | LSF_FILE | _fFile, |
LSVOID * | _pvBuffer, | ||
LSUINTPTR | _uiptrBytesToRead | ||
) | [static] |
Read from a file. Returns false under any form of error. If true is returned, the full amount of data was read from the file to the buffer.
_fFile | Handle to the opened file from which to read. |
_pvBuffer | Buffer to store the data read from the file. This must be long enough to hold _uiptrBytesToRead bytes. |
_uiptrBytesToRead | Number of bytes to read from the file. |
static LSBOOL LSE_CALL lsf::CFileLib::SetFilePointer | ( | LSF_FILE | _fFile, |
LSINT64 | _i64DistanceToMove, | ||
LSF_SEEK | _sMoveMethod | ||
) | [static] |
Moves the file pointer of the specified file.
_fFile | A handle to the file. |
_i64DistanceToMove | The number of bytes to move the file pointer. A positive value moves the pointer forward in the file and a negative value moves the file pointer backward. |
_sMoveMethod | The starting point for the file pointer move. Must be one of the LSF_SEEK enumerated values. |
static LSVOID LSE_CALL lsf::CFileLib::SetResPath | ( | const LSCHAR * | _pcPath | ) | [static] |
Sets the resource path.
_pcPath | The resource path to set. |
static LSVOID LSE_CALL lsf::CFileLib::UnMap | ( | const LSVOID * | _pvAddr, |
LSUINTPTR | _uiptrLen | ||
) | [static] |
static LSBOOL LSE_CALL lsf::CFileLib::WriteFile | ( | LSF_FILE | _fFile, |
const LSVOID * | _pvBuffer, | ||
LSUINTPTR | _uiptrBytesToWrite | ||
) | [static] |
Write to a file. Returns false under any form of error. Data is written starting at the current position in the file.
_fFile | Handle to the opened file to which to write. Must have been opened with either LSF_OF_WRITE or LSF_OF_APPEND. |
_pvBuffer | Data to write to the file. |
_uiptrBytesToWrite | Number of bytes to copy from _pvBuffer to the file. |
LSCHAR lsf::CFileLib::m_szResourcePath[LSF_MAX_PATH] [static, protected] |
The resource path.
LSUINT32 lsf::CFileLib::m_ui32ResPathLen [static, protected] |
Length of the resource path in characters.