VOGONS


First post, by superfury

User metadata
Rank l33t
Rank
l33t

I'm trying to get my 64-bit file I/O in UniPCemu to be cross-platform completely. The reads and writes to files have no complications(since they use the internal number to keep track of the current file position), but _fseeki64 and _ftelli64 seems to have problems with e.g. MinGW builds?

#if defined(VISUALC) || (defined(_fseeki64) && defined(_ftelli64))
if (!(result = _fseeki64(b->f, pos, direction))) //Direction is constant itself!
{
b->position = _ftelli64(b->f); //Use our own position indicator!
}
#elif defined(fseeki64) && defined(ftelli64)
if (!(result = fseeki64(b->f, pos, direction))) //Direction is constant itself!
{
b->position = ftelli64(b->f); //Use our own position indicator!
}
#elif defined(_fseeko64) && defined(_ftello64)
if (!(result = _fseeko64(b->f, pos, direction))) //Direction is constant itself!
{
b->position = _ftello64(b->f); //Use our own position indicator!
}
#elif defined(fseeko64) && defined(ftello64)
if (!(result = fseeko64(b->f, pos, direction))) //Direction is constant itself!
{
b->position = ftello64(b->f); //Use our own position indicator!
}
#elif defined(_fseeko) && defined(_ftello)
if (!(result = _fseeko(b->f, pos, direction))) //Direction is constant itself!
{
b->position = _ftello(b->f); //Use our own position indicator!
}
#elif defined(fseeko) && defined(ftello)
if (!(result = fseeko(b->f, pos, direction))) //Direction is constant itself!
{
b->position = ftello(b->f); //Use our own position indicator!
}
#else
if (!(result = fseek(b->f, pos, direction))) //Direction is constant itself!
{
b->position = ftell(b->f); //Use our own position indicator!
}
#endif

For some reason, it ends up at the normal fseek and ftell when using MinGW?

Anyone?

UniPCemu Git repository
UniPCemu for Android, Windows and PSP on itch.io
Older UniPCemu PC/Android/PSP releases

Reply 1 of 1, by superfury

User metadata
Rank l33t
Rank
l33t

Having revised this code to:

#ifdef IS_WINDOWS
if (!(result = _fseeki64(b->f, pos, direction))) //Direction is constant itself!
{
b->position = _ftelli64(b->f); //Use our own position indicator!
}
#elif defined(IS_LINUX)
if (!(result = fseeko(b->f, pos, direction))) //Direction is constant itself!
{
b->position = ftello(b->f); //Use our own position indicator!
}
#else
if (!(result = fseek(b->f, pos, direction))) //Direction is constant itself!
{
b->position = ftell(b->f); //Use our own position indicator!
}
#endif

This should have fixed any portability issues(with both Android and Windows having improved behaviour on this(Android builds define IS_LINUX in the UniPCemu(common emulator framework) headers)).

UniPCemu Git repository
UniPCemu for Android, Windows and PSP on itch.io
Older UniPCemu PC/Android/PSP releases