File abstraction layer can't open files in binary mode in Linux
#1
In Linux, the variable O_BINARY is 0, since all files are assumed to be binary, including text files. In Windows, it is some power of 2. This difference leads to math errors that crop up using dll_fopen on a binary file. See XBMC/xbmc/cores/DllLoader/exports/emu_msvcrt.cpp for details on how O_BINARY is being used.

For the sake of consistency, I modified other lines of code in my fix as well.

To reproduce the bug/test the fix, use this code somewhere in the program on a binary file:
FILE *localFile;
FILE *ftpFile;

char localBuffer[1024];
char ftpBuffer[1024];

assert((localFile = dll_fopen("/home/mbuchoff/Desktop/Artists/3 Doors Down/Folder.jpg", "rb")) != NULL);
assert((ftpFile = dll_fopen("ftp://xbox:[email protected]/F/Music/Artists/3 Doors Down/Folder.jpg", "rb")) != NULL);

for (int i = 0; i < 1024; i++)
{

localBuffer[i] = 0;
ftpBuffer[i] = 1;

}

assert(dll_fread(localBuffer, 1024/8, 8, localFile) == 8);
assert(dll_fread(ftpBuffer, 1024/8, 8, ftpFile) == 8);

for (int i = 0; i < 1024; i++) assert(localBuffer[i] == ftpBuffer[i]);

http://trac.xbmc.org/ticket/5525
Reply

Logout Mark Read Team Forum Stats Members Help
File abstraction layer can't open files in binary mode in Linux0