- if (fileInfo.suffix().compare("zip", Qt::CaseInsensitive) == 0)
- {
- uint8 * buffer = NULL;
- uint32 size = GetFileFromZIP(fileInfo.canonicalFilePath().toAscii(), FT_SOFTWARE, buffer);
+//
+// This handles file identification and ZIP extraction.
+//
+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;
+
+ 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);
+
+ if (fileSize == 0)
+ return;
+ }
+ else
+ {
+ QFile file(fileInfo.filePath());
+
+ if (!file.open(QIODevice::ReadOnly))
+ return;
+
+ fileSize = fileInfo.size();
+
+ if (fileSize == 0)
+ return;
+
+ buffer = new uint8[fileSize];
+ file.read((char *)buffer, fileSize);
+ file.close();
+ }
+
+ // Try to divine the file type by size & header
+ int fileType = ParseFileType(buffer, fileSize);
+
+ // Check for Alpine ROM w/Universal Header
+ bool foundUniversalHeader = HasUniversalHeader(buffer, fileSize);
+ uint32 crc;