![]() |
Gray C++ Libraries
0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
|
#include <cFile.h>
Public Member Functions | |
cFile () | |
cFile (cStringF sFilePath, OF_FLAGS_t nOpenFlags) | |
virtual | ~cFile () |
virtual bool | isValidCheck () const noexcept |
< memory allocation and structure definitions are valid. More... | |
virtual STREAM_SEEKRET_t | Seek (STREAM_OFFSET_t lOffset=0, SEEK_ORIGIN_TYPE eSeekOrigin=SEEK_Set) override |
virtual STREAM_POS_t | GetPosition () const override |
virtual STREAM_POS_t | GetLength () const override |
int | Read (void *pData, size_t nDataSize) |
void | Write (const void *pData, size_t nDataSize) |
cStringF | get_FilePath () const |
cStringF | get_FileTitleX () const |
cStringF | get_FileExt () const |
bool | IsFileExt (const FILECHAR_t *pszExt) const |
OF_FLAGS_t | get_Mode () const noexcept |
OF_FLAGS_t | get_ModeFlags () const noexcept |
bool | isModeWrite () const noexcept |
bool | isModeRead () const noexcept |
virtual bool | isFileOpen () const |
virtual HRESULT | OpenX (cStringF sFilePath="", OF_FLAGS_t nOpenFlags=OF_READ|OF_SHARE_DENY_NONE) |
virtual void | Close (void) override |
HANDLE | DetachFileHandle () |
HRESULT | OpenWait (cStringF sFilePath="", OF_FLAGS_t nOpenFlags=OF_READ|OF_SHARE_DENY_NONE, TIMESYSD_t nWaitTime=100) |
HRESULT | OpenCreate (cStringF sFilePath="", OF_FLAGS_t nOpenFlags=OF_CREATE|OF_WRITE, _SECURITY_ATTRIBUTES *pSa=nullptr) |
bool | SetFileTime (const cTimeFile *lpCreationTime, const cTimeFile *lpAccessTime, const cTimeFile *lpLastWriteTime) |
bool | SetFileTime (cTimeInt timeCreation, cTimeInt timeLastWrite) |
HRESULT | GetFileStatus (OUT cFileStatus &attr) const |
virtual HRESULT | ReadX (void *pData, size_t nDataSize) override |
virtual HRESULT | WriteX (const void *pData, size_t nDataSize) override |
virtual HRESULT | FlushX () override |
![]() | |
virtual | ~CFile () |
virtual void | SetLength (STREAM_SEEKRET_t dwNewLen) |
HRESULT | Write (const void *pData, size_t nDataSize) |
HRESULT | Read (void *pData, size_t nDataSize) |
![]() | |
virtual | ~CObject () |
virtual void | AssertValid () const |
< memory allocation and structure definitions are valid. More... | |
virtual void | Serialize (cArchive &a) |
![]() | |
void | SeekToBegin () |
STREAM_POS_t | SeekToEnd () |
![]() | |
cStreamInput () noexcept | |
virtual | ~cStreamInput () |
virtual size_t | SetSeekSizeMin (size_t nSizeMin=k_FILE_BLOCK_SIZE) |
virtual HRESULT | ReadX (OUT void *pData, size_t nDataSize) |
HRESULT | ReadAll (OUT cHeapBlock &block, size_t nSizeExtra=0) |
virtual HRESULT | ReadStringLine (OUT char *pszBuffer, StrLen_t iSizeMax) |
virtual HRESULT | ReadStringLine (OUT wchar_t *pszBuffer, StrLen_t iSizeMax) |
HRESULT | ReadT (OUT void *pVal, size_t nSize) |
template<typename TYPE > | |
HRESULT | ReadT (OUT TYPE &val) |
template<typename TYPE > | |
HRESULT | ReadTN (OUT TYPE &val) |
HRESULT | ReadSize (OUT size_t &nSize) |
template<typename TYPE > | |
HRESULT | ReadSizeT (OUT TYPE &n) |
HRESULT | ReadHashCode (OUT UINT32 &nHashCode) |
HRESULT | ReadHashCode (OUT UINT64 &nHashCode) |
HRESULT | ReadN (OUT BYTE *pBuffer, size_t nSizeMax) |
template<typename _CH > | |
HRESULT | ReadStringN (OUT _CH *pszStr, StrLen_t iSizeMax) |
virtual HRESULT | ReadPeek (void *pData, size_t nDataSize) |
![]() | |
virtual | ~cStreamBase () |
void | SeekToBegin () |
STREAM_POS_t | SeekToEnd () |
![]() | |
cStreamOutput () noexcept | |
virtual | ~cStreamOutput () |
HRESULT | WriteT (const void *pVal, size_t nDataSize) |
template<typename TYPE > | |
HRESULT | WriteT (TYPE val) |
HRESULT | WriteSize (size_t nSize) |
HRESULT | WriteHashCode (HASHCODE_t nHashCode) |
HRESULT | WriteN (const void *pBuffer, size_t nSize) |
template<typename _CH > | |
HRESULT | WriteStringN (const _CH *pszStr) |
template<typename _CH > | |
HRESULT | WriteCharRepeat (_CH nChar, int nCount=1) |
virtual HRESULT | WriteString (const char *pszStr) |
virtual HRESULT | WriteString (const wchar_t *pszStr) |
StrLen_t | VPrintf (const char *pszFormat, va_list args) |
StrLen_t | VPrintf (const wchar_t *pszFormat, va_list args) |
StrLen_t _cdecl | Printf (const char *pszFormat,...) |
StrLen_t _cdecl | Printf (const wchar_t *pszFormat,...) |
HRESULT | WriteStream (cStreamInput &sInp, STREAM_POS_t nSizeMax=k_FILE_BLOCK_SIZE, IStreamProgressCallback *pProgress=nullptr, TIMESYSD_t nTimeout=0) |
Copy cStreamInput to this stream. More... | |
Static Public Member Functions | |
static HRESULT __stdcall | DeletePath (const FILECHAR_t *pszFileName) |
static HRESULT __stdcall | DeletePathX (const FILECHAR_t *pszFilePath, DWORD nFileFlags=0) |
static HRESULT __stdcall | LoadFile (const FILECHAR_t *pszFilePath, OUT cHeapBlock &block, size_t nSizeExtra=0) |
Protected Member Functions | |
HRESULT | OpenSetup (cStringF sFilePath, OF_FLAGS_t uModeFlags) |
![]() | |
bool | isFileOpen () const noexcept |
HRESULT | OpenCreate (cStringF sFilePath="", OF_FLAGS_t nOpenFlags=OF_CREATE|OF_WRITE, _SECURITY_ATTRIBUTES *pSa=nullptr) |
Protected Attributes | |
OF_FLAGS_t | m_nOpenFlags |
MMSYSTEM uses high bits of 32 bit flags. OF_FLAGS_TYPE_ OF_READ etc. More... | |
![]() | |
cStringF | m_strFileName |
store a copy of the full file path. MFC defined name. More... | |
Static Protected Attributes | |
static ITERATE_t | sm_iFilesOpen = 0 |
global count of all open files for this process. More... | |
Friends | |
class | cFileTests |
Additional Inherited Members | |
![]() | |
cOSHandle | m_hFile |
OSHandle for the open file. More... | |
![]() | |
static const BYTE | k_SIZE_MASK = 0x80 |
Used for WriteSize() More... | |
static const size_t | k_FILE_BLOCK_SIZE = (32 * 1024) |
default arbitrary transfer block size. more than this is NOT more efficient. More... | |
General OS file access interface. Extends MFC functionality
|
inline |
|
inline |
|
inlinevirtual |
|
overridevirtual |
|
static |
Use 'DeletePath' name because windows uses a "#define" macro to overload DeleteFile()! Same as MFC CFile::Remove()
|
static |
Delete this file and fix collisions and read only marking.
HANDLE Gray::cFile::DetachFileHandle | ( | ) |
|
overridevirtual |
synchronous flush of write data to file.
Reimplemented from Gray::cStreamOutput.
Reimplemented in Gray::cFileText.
cStringF Gray::cFile::get_FileExt | ( | ) | const |
get the EXTension including the . Must replace the stupid MFC version of this.
|
inline |
like _MFC_VER CFile::GetFilePath(); but cStringF
cStringF Gray::cFile::get_FileTitleX | ( | ) | const |
Get file name and ext Don't use MFC GetFileTitle() since MFC does not include EXT
|
inlinenoexcept |
get basic set of OF_FLAGS_t. get rid of OF_NONCRIT type flags. e.g. OF_READ
|
inlinenoexcept |
Get the full/hidden elements of the OF_FLAGS_t Flags. e.g. OF_NONCRIT
HRESULT Gray::cFile::GetFileStatus | ( | OUT cFileStatus & | attr | ) | const |
Get the file status info by its open handle Similar to CFile::GetStatus() Same as cFileDir::ReadFileStatus()
|
inlineoverridevirtual |
disambiguate. cStream should be same as FILE_SIZE_t?
Reimplemented from Gray::CFile.
Reimplemented in GrayLib::cFileMem.
|
inlineoverridevirtual |
disambiguate. cStream should be same as FILE_SIZE_t?
Reimplemented from Gray::CFile.
Reimplemented in GrayLib::cFileMem, and Gray::cFileText.
bool Gray::cFile::IsFileExt | ( | const FILECHAR_t * | pszExt | ) | const |
is the pszExt a match?
|
inlinevirtual |
Reimplemented in GrayLib::cFileMem, and Gray::cFileText.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinevirtualnoexcept |
< memory allocation and structure definitions are valid.
Reimplemented from Gray::CObject.
|
static |
Read file into memory.
HRESULT Gray::cFile::OpenCreate | ( | cStringF | sFilePath = "" , |
OF_FLAGS_t | nOpenFlags = OF_CREATE | OF_WRITE , |
||
_SECURITY_ATTRIBUTES * | pSa = nullptr |
||
) |
Open a file by name.
|
protected |
Internal function to set internal params. Similar to SetFilePath() in MFC ?
HRESULT Gray::cFile::OpenWait | ( | cStringF | sFilePath = "" , |
OF_FLAGS_t | nOpenFlags = OF_READ | OF_SHARE_DENY_NONE , |
||
TIMESYSD_t | nWaitTime = 100 |
||
) |
Try to open the file. Wait for a bit if it fails to open. If the file is locked because 'access is denied' then just wait and keep trying.
|
virtual |
Reimplemented in GrayLib::cScriptFileReader, GrayLib::cFileMem, and Gray::cFileText.
|
inline |
|
overridevirtual |
Read a block from the stream. advance the current position.
Reimplemented in GrayLib::cFileMem, and Gray::cFileText.
|
inlineoverridevirtual |
disambiguate cStream not const in MFC
Reimplemented from Gray::CFile.
Reimplemented in Gray::cFileText, and GrayLib::cFileMem.
bool Gray::cFile::SetFileTime | ( | const cTimeFile * | lpCreationTime, |
const cTimeFile * | lpAccessTime, | ||
const cTimeFile * | lpLastWriteTime | ||
) |
Set the time access for an open file. lpAccessTime = can be null.
Use HResult::GetLastDef() to find out why this fails.
|
inline |
|
overridevirtual |
Write a block to the stream. advance the current position.
Reimplemented from Gray::cStreamOutput.
Reimplemented in GrayLib::cFileMem, and Gray::cFileText.
|
friend |
|
protected |
MMSYSTEM uses high bits of 32 bit flags. OF_FLAGS_TYPE_ OF_READ etc.
|
staticprotected |
global count of all open files for this process.