Windows CE/Mobile突破2G文件读写的限制
The declaration of CFile actually already has a big-file operation interface
However, in Windows CE/Mobile, it still doesn't support 4G-file I/O.
The secret is in the implementation of CFile in filecore.cpp, as follows:
ULONGLONG CFile::Seek(LONGLONG lOff, UINT nFrom)
{
...
liOff.LowPart = ::SetFilePointer(m_hFile, liOff.LowPart,
#ifndef _WIN32_WCE // ----------> the macro BLOCK Windows CE/Mobile from supporting big files!!!
&liOff.HighPart,
#else // !_WIN32_WCE
NULL,
#endif // !_WIN32_WCE // -------> BLOCK Windows CE/Mobile from supporting big files!!!
return liOff.QuadPart;
}
The root cause is simple:
the macro __WIN32_WCE blocks reading/writing big files.
Actually, whether support big-file I/O depends on the functionality of SetFilePointer(),
fortunately it supports reading/writing a big file with size more than 2G in Windows CE/Mobile.
So, the simplest method to let Windows CE/Mobile support that could be the following code,
very simple:
A famous stupid implementation could be found in the following URL, personally think it is stupid
and low-efficient. Why not directly copy MFC code, and make little change?
By the way, the biggest file size in FAT32 system is 4G. Most SD cards only support FAT32.