diff options
author | Max Horn | 2009-11-23 22:30:22 +0000 |
---|---|---|
committer | Max Horn | 2009-11-23 22:30:22 +0000 |
commit | 6b8dd7ab7af6353f656ece14fe13c6cc4a93c5e3 (patch) | |
tree | ad77e0b705af0f8703a8fc987175ceb20cde5dc2 /engines | |
parent | 3d342bec3c099039efe2452b08ea525002eac7b2 (diff) | |
download | scummvm-rg350-6b8dd7ab7af6353f656ece14fe13c6cc4a93c5e3.tar.gz scummvm-rg350-6b8dd7ab7af6353f656ece14fe13c6cc4a93c5e3.tar.bz2 scummvm-rg350-6b8dd7ab7af6353f656ece14fe13c6cc4a93c5e3.zip |
COMMON: Remove various variants of the md5_file / md5_file_string funcs; turned the (disabled) MD5 test code into a working unit test
svn-id: r46108
Diffstat (limited to 'engines')
-rw-r--r-- | engines/advancedDetector.cpp | 16 | ||||
-rw-r--r-- | engines/scumm/detection.cpp | 3 | ||||
-rw-r--r-- | engines/scumm/file_nes.cpp | 4 | ||||
-rw-r--r-- | engines/tinsel/detection.cpp | 12 |
4 files changed, 21 insertions, 14 deletions
diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp index 7d86f3ef32..1c60ea949d 100644 --- a/engines/advancedDetector.cpp +++ b/engines/advancedDetector.cpp @@ -370,16 +370,18 @@ static ADGameDescList detectGame(const Common::FSList &fslist, const ADParams &p debug(3, "+ %s", fname.c_str()); SizeMD5 tmp; - if (!md5_file_string(allFiles[fname], tmp.md5, params.md5Bytes)) - tmp.md5[0] = 0; - - debug(3, "> '%s': '%s'", fname.c_str(), tmp.md5); - Common::File testFile; - if (testFile.open(allFiles[fname])) + + if (testFile.open(allFiles[fname])) { tmp.size = (int32)testFile.size(); - else + if (!md5_file_string(testFile, tmp.md5, params.md5Bytes)) + tmp.md5[0] = 0; + } else { tmp.size = -1; + tmp.md5[0] = 0; + } + + debug(3, "> '%s': '%s'", fname.c_str(), tmp.md5); filesSizeMD5[fname] = tmp; } diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp index 4d984caa6d..c23d8a5529 100644 --- a/engines/scumm/detection.cpp +++ b/engines/scumm/detection.cpp @@ -378,7 +378,8 @@ static void detectGames(const Common::FSList &fslist, Common::List<DetectorResul // DetectorDesc &d = fileMD5Map[file]; if (d.md5.empty()) { - if (Common::md5_file_string(d.node, md5str, kMD5FileSizeLimit)) { + Common::File tmp; + if (tmp.open(d.node) && Common::md5_file_string(tmp, md5str, kMD5FileSizeLimit)) { d.md5 = md5str; d.md5Entry = findInMD5Table(md5str); diff --git a/engines/scumm/file_nes.cpp b/engines/scumm/file_nes.cpp index e2604039a4..27840b6865 100644 --- a/engines/scumm/file_nes.cpp +++ b/engines/scumm/file_nes.cpp @@ -1371,7 +1371,9 @@ bool ScummNESFile::open(const Common::String &filename) { if (_ROMset == kROMsetNum) { char md5str[32+1]; - if (Common::md5_file_string(filename.c_str(), md5str)) { + File f; + f.open(filename); + if (f.isOpen() && Common::md5_file_string(f, md5str)) { if (!strcmp(md5str, "3905799e081b80a61d4460b7b733c206")) { _ROMset = kROMsetUSA; diff --git a/engines/tinsel/detection.cpp b/engines/tinsel/detection.cpp index 038c0c9625..e4ee52247e 100644 --- a/engines/tinsel/detection.cpp +++ b/engines/tinsel/detection.cpp @@ -740,14 +740,16 @@ const ADGameDescription *TinselMetaEngine::fallbackDetect(const Common::FSList & Common::String fname(tempFilename); if (allFiles.contains(fname) && !filesSizeMD5.contains(fname)) { SizeMD5 tmp; - if (!md5_file_string(allFiles[fname], tmp.md5, detectionParams.md5Bytes)) - tmp.md5[0] = 0; - Common::File testFile; - if (testFile.open(allFiles[fname])) + + if (testFile.open(allFiles[fname])) { tmp.size = (int32)testFile.size(); - else + if (!md5_file_string(testFile, tmp.md5, detectionParams.md5Bytes)) + tmp.md5[0] = 0; + } else { tmp.size = -1; + tmp.md5[0] = 0; + } filesSizeMD5[fname] = tmp; } |