Here's my code:
Code: Select all
void androidExtractFiles()
{
#ifdef _IRR_ANDROID_PLATFORM_
ANativeActivity* nativeActivity = Game::state->activity;
Game::setAndroidInternalPath((std::string)nativeActivity->internalDataPath + "/");
for ( u32 i=0; i < Game::device->getFileSystem()->getFileArchiveCount(); ++i )
{
IFileArchive* archive = Game::device->getFileSystem()->getFileArchive(i);
if ( archive->getType() == EFAT_ANDROID_ASSET )
{
archive->addDirectoryToFileList("Files/"); // I do this for all folders and subfolders
// ...
IFileList* files = (IFileList*)archive->getFileList();
for (int x = 0; x < files->getFileCount(); x++)
{
Game::log("FILE: " + (std::string)files->getFullFileName(x).c_str());
std::string fName = Game::getAndroidInternalPath() + files->getFullFileName(x).c_str();
if (!files->isDirectory(x) && Operations::readFile(fName) == 0)
{
Game::log("EXTRACTING.\n");
IReadFile* f = archive->createAndOpenFile(files->getFullFileName(x));
int len = f->getSize();
char* buf = new char[len+1];
f->read(buf, len);
f->drop();
buf[len] = '\0';
Operations::createDirectories(fName); // creates any folders that don't exist for the file
FILE* fi = fopen(fName.c_str(), "wb");
fwrite(buf, 1, len, fi);
fclose(fi);
delete [] buf;
if (Operations::readFile(fName) != 0)
Game::log("Extracted OK.");
}
}
break;
}
}
#endif // _IRR_ANDROID_PLATFORM_
}
When I hash the file and check it against the hash of a file on the server (which should be the exact same files), they are different and I cannot see how.
I know the hashing is working fine, as once the server sends the file to the client and I check the hash again, they are the same. They are not the same only when extracted in the above code.
Assume that Operations::readFile() is correct.
I can't seem to figure out what I'm doing wrong, any suggestions?