X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fgui%2Ffilethread.cpp;h=22bf3b72f09afc258f0e8cc4671c640326daea2a;hb=ec553d06e2718a1c6c0d6bdfcd508ce1ba89c706;hp=3229c3521a4bb5c2445ff8198067d8a21bae1305;hpb=b79146c85ed8f85acc80fe56534f72cd777f0b02;p=virtualjaguar diff --git a/src/gui/filethread.cpp b/src/gui/filethread.cpp index 3229c35..22bf3b7 100644 --- a/src/gui/filethread.cpp +++ b/src/gui/filethread.cpp @@ -10,12 +10,14 @@ // --- ---------- ------------------------------------------------------------- // JLH 01/28/2010 Created this file // JLH 02/16/2010 Moved RomIdentifier stuff to its own file +// JLH 03/02/2010 Added .ZIP file fishing // #include "filethread.h" #include #include "crc32.h" +#include "file.h" #include "filedb.h" #include "settings.h" @@ -81,23 +83,65 @@ printf("FileThread: Aborting!!!\n"); #endif QFileInfo fileInfo = list.at(i); - QFile file(romDir.filePath(fileInfo.fileName())); - uint8 * buffer = new uint8[fileInfo.size()]; - if (file.open(QIODevice::ReadOnly)) + // 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 + if (fileInfo.suffix().compare("zip", Qt::CaseInsensitive) == 0) { - file.read((char *)buffer, fileInfo.size()); - uint32 crc = crc32_calcCheckSum(buffer, fileInfo.size()); - file.close(); + uint8 * buffer = NULL; + uint32 size = GetFileFromZIP(fileInfo.canonicalFilePath().toAscii(), FT_SOFTWARE, buffer); - uint32 index = FindCRCIndexInFileList(crc); + if (size > 0) + { +//printf("FileThread: About to calc checksum on file with size %u... (buffer=%08X)\n", size, buffer); + uint32 crc = crc32_calcCheckSum(buffer, size); + uint32 index = FindCRCIndexInFileList(crc); + delete[] buffer; // Mebbe we should pass a index AND a QImage here??? - if (index != 0xFFFFFFFF && !(romList[index].flags & FF_BIOS)) - emit FoundAFile(index); +/* +Let's think about this... What *do* we need to send out? +we need the filename for sure. image file if it exists. +do we need the index? I think we're only using it to pull the label from the subdir... +we might need it if we want to pull ROM flags from the fileDB... +*/ + if (index != 0xFFFFFFFF && !(romList[index].flags & FF_BIOS)) + { + QImage img; + size = GetFileFromZIP(fileInfo.canonicalFilePath().toAscii(), FT_LABEL, buffer); + + if (size > 0) + { + img.loadFromData(buffer, size); + delete[] buffer; + } +//printf("FileThread: Attempted to load image. Size: %u x %u...\n", img.width(), img.height()); + +// emit FoundAFile(index); + emit FoundAFile2(index, fileInfo.canonicalFilePath(), &img); + } + } } + else + { + QFile file(romDir.filePath(fileInfo.fileName())); - delete[] buffer; + if (file.open(QIODevice::ReadOnly)) + { + uint8 * buffer = new uint8[fileInfo.size()]; + file.read((char *)buffer, fileInfo.size()); + file.close(); + uint32 crc = crc32_calcCheckSum(buffer, fileInfo.size()); + uint32 index = FindCRCIndexInFileList(crc); + delete[] buffer; + +// Mebbe we should pass a index AND a QImage here??? + if (index != 0xFFFFFFFF && !(romList[index].flags & FF_BIOS)) +// emit FoundAFile(index); + emit FoundAFile2(index, fileInfo.canonicalFilePath(), 0); + } + } } }