summaryrefslogtreecommitdiffstatshomepage
path: root/src/tools/romcmp.cpp
diff options
context:
space:
mode:
author therealmogminer@gmail.com <therealmogminer@gmail.com>2016-03-21 08:27:06 +0100
committer therealmogminer@gmail.com <therealmogminer@gmail.com>2016-03-21 08:27:06 +0100
commita99df788017c2bf5a56034d4f9152bf8ab95a168 (patch)
tree3beec27b413c75b8f9f88199519e45fd07959bf8 /src/tools/romcmp.cpp
parentb224d9a77ad6483daf2b60b75dbdc323a3bcd4b0 (diff)
parent3afd990226a2c647290579bebb5537bd0fd3faac (diff)
Merge with master
Diffstat (limited to 'src/tools/romcmp.cpp')
-rw-r--r--src/tools/romcmp.cpp50
1 files changed, 24 insertions, 26 deletions
diff --git a/src/tools/romcmp.cpp b/src/tools/romcmp.cpp
index 4d89718abe9..641667b6342 100644
--- a/src/tools/romcmp.cpp
+++ b/src/tools/romcmp.cpp
@@ -393,11 +393,11 @@ static float filecompare(const fileinfo *file1,const fileinfo *file2,int mode1,i
static void readfile(const char *path,fileinfo *file)
{
- file_error filerr;
+ osd_file::error filerr;
UINT64 filesize;
UINT32 actual;
char fullname[256];
- osd_file *f = nullptr;
+ osd_file::ptr f;
if (path)
{
@@ -414,22 +414,19 @@ static void readfile(const char *path,fileinfo *file)
return;
}
- filerr = osd_open(fullname, OPEN_FLAG_READ, &f, &filesize);
- if (filerr != FILERR_NONE)
+ filerr = osd_file::open(fullname, OPEN_FLAG_READ, f, filesize);
+ if (filerr != osd_file::error::NONE)
{
- printf("%s: error %d\n", fullname, filerr);
+ printf("%s: error %d\n", fullname, int(filerr));
return;
}
- filerr = osd_read(f, file->buf, 0, file->size, &actual);
- if (filerr != FILERR_NONE)
+ filerr = f->read(file->buf, 0, file->size, actual);
+ if (filerr != osd_file::error::NONE)
{
- printf("%s: error %d\n", fullname, filerr);
- osd_close(f);
+ printf("%s: error %d\n", fullname, int(filerr));
return;
}
-
- osd_close(f);
}
@@ -493,43 +490,45 @@ static int load_files(int i, int *found, const char *path)
/* if not, try to open as a ZIP file */
else
{
- zip_file *zip;
- const zip_file_header* zipent;
- zip_error ziperr;
+ util::archive_file::ptr zip;
/* wasn't a directory, so try to open it as a zip file */
- ziperr = zip_file_open(path, &zip);
- if (ziperr != ZIPERR_NONE)
+ if ((util::archive_file::open_zip(path, zip) != util::archive_file::error::NONE) &&
+ (util::archive_file::open_7z(path, zip) != util::archive_file::error::NONE))
{
printf("Error, cannot open zip file '%s' !\n", path);
return 1;
}
/* load all files in zip file */
- for (zipent = zip_file_first_file(zip); zipent != nullptr; zipent = zip_file_next_file(zip))
+ for (int zipent = zip->first_file(); zipent >= 0; zipent = zip->next_file())
{
+ if (zip->current_is_directory()) continue;
+
int size;
- size = zipent->uncompressed_length;
+ size = zip->current_uncompressed_length();
while (size && (size & 1) == 0) size >>= 1;
- if (zipent->uncompressed_length == 0) // || (size & ~1))
+ if (zip->current_uncompressed_length() == 0) // || (size & ~1))
+ {
printf("%-23s %-23s ignored (not a ROM)\n",
- i ? "" : zipent->filename, i ? zipent->filename : "");
+ i ? "" : zip->current_name().c_str(), i ? zip->current_name().c_str() : "");
+ }
else
{
fileinfo *file = &files[i][found[i]];
- const char *delim = strrchr(zipent->filename,'/');
+ const char *delim = strrchr(zip->current_name().c_str(), '/');
if (delim)
strcpy (file->name,delim+1);
else
- strcpy(file->name,zipent->filename);
- file->size = zipent->uncompressed_length;
+ strcpy(file->name,zip->current_name().c_str());
+ file->size = zip->current_uncompressed_length();
if ((file->buf = (unsigned char *)malloc(file->size)) == nullptr)
printf("%s: out of memory!\n",file->name);
else
{
- if (zip_file_decompress(zip, (char *)file->buf, file->size) != ZIPERR_NONE)
+ if (zip->decompress(file->buf, file->size) != util::archive_file::error::NONE)
{
free(file->buf);
file->buf = nullptr;
@@ -545,7 +544,6 @@ static int load_files(int i, int *found, const char *path)
found[i]++;
}
}
- zip_file_close(zip);
}
return 0;
}
@@ -747,6 +745,6 @@ int CLIB_DECL main(int argc,char *argv[])
}
}
- zip_file_cache_clear();
+ util::archive_file::cache_clear();
return 0;
}