Hi!
I am in the proces of finishing PocketAdventures
(Don't tell anyone
)
Everything is working fine on the PC, and the translation to PocketPC goes very well.
I use gapitools, and all my source is
compatible between PocketPC and PC.
Theres only one thing i cant get working on the PocketPC and that is :
How can i read a textfile into a Cstring?
On the pc i use this code:
Somehow this isnt compatible with PocketPc.
I know it is something very simple (i think
it has something to do with UNICODE and TEXT macros).
Greetz,
kaiton
I am in the proces of finishing PocketAdventures
(Don't tell anyone
Everything is working fine on the PC, and the translation to PocketPC goes very well.
I use gapitools, and all my source is
compatible between PocketPC and PC.
Theres only one thing i cant get working on the PocketPC and that is :
How can i read a textfile into a Cstring?
On the pc i use this code:
void CMainFrame::LoadGame(CString File)
{
#ifndef _WIN32_WCE
FILE *fp;
CString err_msg;
CString file;
long f_size;
LPTSTR s;
// Open the file in text mode to do
// CR-LF -> LF converison.
if (NULL == (fp = fopen((LPCTSTR)File, "r")))
{
err_msg = File + ": " + strerror(errno);
MessageBox(err_msg, "Open", MB_OK | MB_ICONERROR);
return;
}
fseek(fp, 0, SEEK_END);
f_size = ftell(fp); // Acutal size of file - just used to set
// CString large enough - may read
// less if any CRs in file
s = file.GetBufferSetLength((int)f_size + 1);
fseek(fp, 0, SEEK_SET);
// f_size will change if there were any
// CRs in the file.
f_size = fread(s, 1, f_size, fp);
*(s + f_size) = '\0'; // NULL-terminate as we are using
// ReleaseBuffer(-1) to set file
// to the exact size.
file.ReleaseBuffer(-1);
fclose(fp);
RunScript(file);
#endif
Somehow this isnt compatible with PocketPc.
I know it is something very simple (i think
it has something to do with UNICODE and TEXT macros).
Greetz,
kaiton