從MPQ包中讀取二進位制流出來然後檔案寫到硬碟。
DWORD size = SFileGetSize(hFile);
char* buffer = new char[size];
std::ofstream ofs;
ofs.open(name);
ASSERT(ofs.good());
ofs.write(buffer, size);
ASSERT(ofs.good());
ofs.close();
.xml,.lua,等文字都是對的,唯獨.jpg這些圖片些不對!
open改為ofs.open(name, std::ios::out | std::ios::binary);
就對了!
原因應該是ofstream開啟檔案時預設是文字格式吧。。。
void open( const char *_Filename, ios_base::openmode _Mode = ios_base::out, int _Prot = (int)ios_base::_Openprot ); void open( const char *_Filename, ios_base::openmode _Mode ); void open( const wchar_t *_Filename, ios_base::openmode _Mode = ios_base::out, int _Prot = (int)ios_base::_Openprot ); void open( const wchar_t *_Filename, ios_base::openmode _Mode );