X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fgui%2Ffilethread.cpp;h=e3b5ffd48a364ee2a12df75373088f244e1f7721;hb=d207b11e613703aff7d00191c4595b7359f29700;hp=3b8793c31ffbd3fc6048ddb293ea3c9db17265cb;hpb=828059a53ae8bfb03ade4acd1e62c8de9be89775;p=virtualjaguar diff --git a/src/gui/filethread.cpp b/src/gui/filethread.cpp index 3b8793c..e3b5ffd 100644 --- a/src/gui/filethread.cpp +++ b/src/gui/filethread.cpp @@ -1,10 +1,10 @@ // // filethread.cpp - File discovery thread // -// by James L. Hammons +// by James Hammons // (C) 2010 Underground Software // -// JLH = James L. Hammons +// JLH = James Hammons // // Who When What // --- ---------- ------------------------------------------------------------- @@ -17,7 +17,6 @@ #include "filethread.h" -#include #include "crc32.h" #include "file.h" #include "filedb.h" @@ -92,17 +91,20 @@ printf("FileThread: Aborting!!!\n"); // void FileThread::HandleFile(QFileInfo fileInfo) { + // Really, need to come up with some kind of cacheing scheme here, so we don't + // fish through these files every time we run VJ :-P +#warning "!!! Need to come up with some kind of cacheing scheme here !!!" bool haveZIPFile = (fileInfo.suffix().compare("zip", Qt::CaseInsensitive) == 0 ? true : false); uint32_t fileSize = 0; - uint8 * buffer = NULL; + uint8_t * buffer = NULL; if (haveZIPFile) { // ZIP files are special: They contain more than just the software now... ;-) // So now we fish around inside them to pull out the stuff we want. // Probably also need more stringent error checking as well... :-O - fileSize = GetFileFromZIP(fileInfo.filePath().toAscii(), FT_SOFTWARE, buffer); + fileSize = GetFileFromZIP(fileInfo.filePath().toUtf8(), FT_SOFTWARE, buffer); if (fileSize == 0) return; @@ -119,17 +121,17 @@ void FileThread::HandleFile(QFileInfo fileInfo) if (fileSize == 0) return; - buffer = new uint8[fileSize]; + buffer = new uint8_t[fileSize]; file.read((char *)buffer, fileSize); file.close(); } // Try to divine the file type by size & header - int fileType = ParseFileType(buffer[0], buffer[1], fileSize); + int fileType = ParseFileType(buffer, fileSize); // Check for Alpine ROM w/Universal Header bool foundUniversalHeader = HasUniversalHeader(buffer, fileSize); - uint32 crc; + uint32_t crc; //printf("FileThread: About to calc checksum on file with size %u... (buffer=%08X)\n", size, buffer); if (foundUniversalHeader) @@ -137,7 +139,7 @@ void FileThread::HandleFile(QFileInfo fileInfo) else crc = crc32_calcCheckSum(buffer, fileSize); - uint32 index = FindCRCIndexInFileList(crc); + uint32_t index = FindCRCIndexInFileList(crc); delete[] buffer; // Here we filter out files that are *not* in the DB and of unknown type, @@ -148,7 +150,7 @@ void FileThread::HandleFile(QFileInfo fileInfo) if (!allowUnknownSoftware) return; // CRC wasn't found, so bail... } - else if (romList[index].flags & FF_BIOS) + else if ((index != 0xFFFFFFFF) && romList[index].flags & FF_BIOS) return; //Here's a little problem. When we create the image here and pass it off to FilePicker, @@ -160,7 +162,7 @@ void FileThread::HandleFile(QFileInfo fileInfo) // See if we can fish out a label. :-) if (haveZIPFile) { - uint32 size = GetFileFromZIP(fileInfo.filePath().toAscii(), FT_LABEL, buffer); + uint32_t size = GetFileFromZIP(fileInfo.filePath().toUtf8(), FT_LABEL, buffer); //printf("FT: Label size = %u bytes.\n", size); if (size > 0) @@ -183,7 +185,7 @@ void FileThread::HandleFile(QFileInfo fileInfo) // Find a CRC in the ROM list (simple brute force algorithm). // If it's there, return the index, otherwise return $FFFFFFFF // -uint32 FileThread::FindCRCIndexInFileList(uint32 crc) +uint32_t FileThread::FindCRCIndexInFileList(uint32_t crc) { // Instead of a simple brute-force search, we should probably do a binary // partition search instead, since the CRCs are sorted numerically.