PDA

View Full Version : getting bad crc32 checksum of rttex files in proton



karelc
08-01-2013, 04:01 PM
So I'm doing crc32 checksums of all files and comparing them to crc32 values from a server. The same code used to generate the values for the server is used in proton to check the local files.
I only have 3 filetypes, .X, .png (used in normal android activities) and .rttex. It works for .X and .png, but all .rttex files return the wrong checksum.
Yes I am positive the files I am comparing are the same :)

The only difference in code is how it reads the file. The tool I have uses fopen etc but in the proton app I can't so I use FileInstance.GetAsChars().
Reading a file to a buffer in my tool:

FILE* file = fopen(path, "rb");
if (file != 0) {
fseek(file, 0, SEEK_END);
unsigned int filesize = ftell(file);
rewind(file);
char* buffer = new char[filesize];
fread(buffer, 1, filesize, file);
fclose(file);

unsigned long crc = (unsigned long)CRC32_ComputeCRC32((const unsigned char*)buffer, filesize);
...
}
that buffer should have the same content as here in proton;

FileInstance file(path);
if (file.GetSize() > 0) {
char* buffer = file.GetAsChars();
unsigned int filesize = (unsigned int)file.GetSize();

unsigned long crc = (unsigned long)CRC32_ComputeCRC32((const unsigned char*)buffer, filesize);
...
}
right?

Like I said the resulting crc is correct for .X, .png, and I imagine many other filetypes, but not for .rttex.
Any idea what's going wrong here?

Seth
08-01-2013, 10:03 PM
On the Proton side, use this instead to get the raw data:

int size;

uint8 *pData = GetFileManager()->Get(fName, &size, false, false);

BTW, you CAN use Proton on your linux server -check the RTConsole example - you just define _CONSOLE and Proton doesn't need App, FileManager, etc, and most commands still work.

For instance, check out unsigned int GetHashOfFile(string fName, bool bAddBasePath) in MiscUtils.cpp.

karelc
08-02-2013, 11:53 AM
Ok that works, thanks.
I know proton runs on almost everything but we have no need for it on the server :)