summaryrefslogtreecommitdiffstatshomepage
path: root/src/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/chdman.cpp16
-rw-r--r--src/tools/imgtool/stream.cpp17
-rw-r--r--src/tools/pngcmp.cpp6
-rw-r--r--src/tools/regrep.cpp10
-rw-r--r--src/tools/romcmp.cpp30
-rw-r--r--src/tools/split.cpp8
-rw-r--r--src/tools/src2html.cpp6
7 files changed, 47 insertions, 46 deletions
diff --git a/src/tools/chdman.cpp b/src/tools/chdman.cpp
index edf7ee0b14a..95dd285a94d 100644
--- a/src/tools/chdman.cpp
+++ b/src/tools/chdman.cpp
@@ -333,7 +333,7 @@ public:
{
m_file.reset();
m_lastfile = m_info.track[tracknum].fname;
- osd_file::error filerr = util::core_file::open(m_lastfile.c_str(), OPEN_FLAG_READ, m_file);
+ osd_file::error filerr = util::core_file::open(m_lastfile, OPEN_FLAG_READ, m_file);
if (filerr != osd_file::error::NONE)
report_error(1, "Error opening input file (%s)'", m_lastfile.c_str());
}
@@ -1574,7 +1574,7 @@ static void do_create_raw(parameters_t &params)
auto input_file_str = params.find(OPTION_INPUT);
if (input_file_str != params.end())
{
- osd_file::error filerr = util::core_file::open(input_file_str->second->c_str(), OPEN_FLAG_READ, input_file);
+ osd_file::error filerr = util::core_file::open(*input_file_str->second, OPEN_FLAG_READ, input_file);
if (filerr != osd_file::error::NONE)
report_error(1, "Unable to open file (%s)", input_file_str->second->c_str());
}
@@ -1671,7 +1671,7 @@ static void do_create_hd(parameters_t &params)
auto input_file_str = params.find(OPTION_INPUT);
if (input_file_str != params.end())
{
- osd_file::error filerr = util::core_file::open(input_file_str->second->c_str(), OPEN_FLAG_READ, input_file);
+ osd_file::error filerr = util::core_file::open(*input_file_str->second, OPEN_FLAG_READ, input_file);
if (filerr != osd_file::error::NONE)
report_error(1, "Unable to open file (%s)", input_file_str->second->c_str());
}
@@ -2240,7 +2240,7 @@ static void do_extract_raw(parameters_t &params)
try
{
// process output file
- osd_file::error filerr = util::core_file::open(output_file_str->second->c_str(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, output_file);
+ osd_file::error filerr = util::core_file::open(*output_file_str->second, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, output_file);
if (filerr != osd_file::error::NONE)
report_error(1, "Unable to open file (%s)", output_file_str->second->c_str());
@@ -2345,14 +2345,14 @@ static void do_extract_cd(parameters_t &params)
}
// process output file
- osd_file::error filerr = util::core_file::open(output_file_str->second->c_str(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_NO_BOM, output_toc_file);
+ osd_file::error filerr = util::core_file::open(*output_file_str->second, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_NO_BOM, output_toc_file);
if (filerr != osd_file::error::NONE)
report_error(1, "Unable to open file (%s)", output_file_str->second->c_str());
// process output BIN file
if (mode != MODE_GDI)
{
- filerr = util::core_file::open(output_bin_file_str->c_str(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, output_bin_file);
+ filerr = util::core_file::open(*output_bin_file_str, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, output_bin_file);
if (filerr != osd_file::error::NONE)
report_error(1, "Unable to open file (%s)", output_bin_file_str->c_str());
}
@@ -2388,7 +2388,7 @@ static void do_extract_cd(parameters_t &params)
output_bin_file.reset();
- filerr = util::core_file::open(trackbin_name.c_str(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, output_bin_file);
+ filerr = util::core_file::open(trackbin_name, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, output_bin_file);
if (filerr != osd_file::error::NONE)
report_error(1, "Unable to open file (%s)", trackbin_name.c_str());
@@ -2795,7 +2795,7 @@ static void do_dump_metadata(parameters_t &params)
// create the file
if (output_file_str != params.end())
{
- osd_file::error filerr = util::core_file::open(output_file_str->second->c_str(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, output_file);
+ osd_file::error filerr = util::core_file::open(*output_file_str->second, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, output_file);
if (filerr != osd_file::error::NONE)
report_error(1, "Unable to open file (%s)", output_file_str->second->c_str());
diff --git a/src/tools/imgtool/stream.cpp b/src/tools/imgtool/stream.cpp
index d96cf325a7a..b11e7a5e4be 100644
--- a/src/tools/imgtool/stream.cpp
+++ b/src/tools/imgtool/stream.cpp
@@ -104,24 +104,23 @@ static imgtool_stream *stream_open_zip(const char *zipname, const char *subname,
imgfile->imgtype = IMG_MEM;
- zip_file::ptr z;
- const zip_file::file_header *zipent = nullptr;
- zip_file::open(zipname, z);
+ util::archive_file::ptr z;
+ util::archive_file::open_zip(zipname, z);
if (!z)
return nullptr;
- zipent = z->first_file();
- while (zipent && subname && strcmp(subname, zipent->filename))
+ int zipent = z->first_file();
+ while ((zipent >= 0) && subname && strcmp(subname, z->current_name().c_str()))
zipent = z->next_file();
- if (!zipent)
+ if (zipent < 0)
return nullptr;
- imgfile->filesize = zipent->uncompressed_length;
- imgfile->buffer = reinterpret_cast<std::uint8_t *>(malloc(zipent->uncompressed_length));
+ imgfile->filesize = z->current_uncompressed_length();
+ imgfile->buffer = reinterpret_cast<std::uint8_t *>(malloc(z->current_uncompressed_length()));
if (!imgfile->buffer)
return nullptr;
- if (z->decompress(imgfile->buffer, zipent->uncompressed_length) != zip_file::error::NONE)
+ if (z->decompress(imgfile->buffer, z->current_uncompressed_length()) != util::archive_file::error::NONE)
return nullptr;
return imgfile.release();
diff --git a/src/tools/pngcmp.cpp b/src/tools/pngcmp.cpp
index aa33a421e5d..e34bcf401e4 100644
--- a/src/tools/pngcmp.cpp
+++ b/src/tools/pngcmp.cpp
@@ -80,7 +80,7 @@ static int generate_png_diff(const std::string& imgfile1, const std::string& img
int x, y;
/* open the source image */
- filerr = util::core_file::open(imgfile1.c_str(), OPEN_FLAG_READ, file);
+ filerr = util::core_file::open(imgfile1, OPEN_FLAG_READ, file);
if (filerr != osd_file::error::NONE)
{
printf("Could not open %s (%d)\n", imgfile1.c_str(), int(filerr));
@@ -97,7 +97,7 @@ static int generate_png_diff(const std::string& imgfile1, const std::string& img
}
/* open the source image */
- filerr = util::core_file::open(imgfile2.c_str(), OPEN_FLAG_READ, file);
+ filerr = util::core_file::open(imgfile2, OPEN_FLAG_READ, file);
if (filerr != osd_file::error::NONE)
{
printf("Could not open %s (%d)\n", imgfile2.c_str(), int(filerr));
@@ -170,7 +170,7 @@ static int generate_png_diff(const std::string& imgfile1, const std::string& img
}
/* write the final PNG */
- filerr = util::core_file::open(outfilename.c_str(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, file);
+ filerr = util::core_file::open(outfilename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, file);
if (filerr != osd_file::error::NONE)
{
printf("Could not open %s (%d)\n", outfilename.c_str(), int(filerr));
diff --git a/src/tools/regrep.cpp b/src/tools/regrep.cpp
index 4d02151672b..0c6d11093c6 100644
--- a/src/tools/regrep.cpp
+++ b/src/tools/regrep.cpp
@@ -565,7 +565,7 @@ static util::core_file::ptr create_file_and_output_header(std::string &filename,
util::core_file::ptr file;
/* create the indexfile */
- if (util::core_file::open(filename.c_str(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS | OPEN_FLAG_NO_BOM, file) != osd_file::error::NONE)
+ if (util::core_file::open(filename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS | OPEN_FLAG_NO_BOM, file) != osd_file::error::NONE)
return util::core_file::ptr();
/* print a header */
@@ -735,7 +735,7 @@ static int compare_screenshots(summary_file *curfile)
fullname = string_format("%s" PATH_SEPARATOR "snap" PATH_SEPARATOR "%s" PATH_SEPARATOR "final.png", lists[listnum].dir, curfile->name);
/* open the file */
- filerr = util::core_file::open(fullname.c_str(), OPEN_FLAG_READ, file);
+ filerr = util::core_file::open(fullname, OPEN_FLAG_READ, file);
/* if that failed, look in the old location */
if (filerr != osd_file::error::NONE)
@@ -744,7 +744,7 @@ static int compare_screenshots(summary_file *curfile)
fullname = string_format("%s" PATH_SEPARATOR "snap" PATH_SEPARATOR "_%s.png", lists[listnum].dir, curfile->name);
/* open the file */
- filerr = util::core_file::open(fullname.c_str(), OPEN_FLAG_READ, file);
+ filerr = util::core_file::open(fullname, OPEN_FLAG_READ, file);
}
/* if that worked, load the file */
@@ -853,7 +853,7 @@ static int generate_png_diff(const summary_file *curfile, std::string &destdir,
tempname = string_format("%s" PATH_SEPARATOR "%s", lists[listnum].dir, srcimgname.c_str());
/* open the source image */
- filerr = util::core_file::open(tempname.c_str(), OPEN_FLAG_READ, file);
+ filerr = util::core_file::open(tempname, OPEN_FLAG_READ, file);
if (filerr != osd_file::error::NONE)
goto error;
@@ -925,7 +925,7 @@ static int generate_png_diff(const summary_file *curfile, std::string &destdir,
}
/* write the final PNG */
- filerr = util::core_file::open(dstfilename.c_str(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, file);
+ filerr = util::core_file::open(dstfilename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, file);
if (filerr != osd_file::error::NONE)
goto error;
pngerr = png_write_bitmap(*file, nullptr, finalbitmap, 0, nullptr);
diff --git a/src/tools/romcmp.cpp b/src/tools/romcmp.cpp
index a6919631cd8..641667b6342 100644
--- a/src/tools/romcmp.cpp
+++ b/src/tools/romcmp.cpp
@@ -490,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::ptr zip;
- const zip_file::file_header* zipent;
- zip_file::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 != zip_file::error::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->first_file(); zipent != nullptr; zipent = zip->next_file())
+ 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->decompress(file->buf, file->size) != zip_file::error::NONE)
+ if (zip->decompress(file->buf, file->size) != util::archive_file::error::NONE)
{
free(file->buf);
file->buf = nullptr;
@@ -743,6 +745,6 @@ int CLIB_DECL main(int argc,char *argv[])
}
}
- zip_file::cache_clear();
+ util::archive_file::cache_clear();
return 0;
}
diff --git a/src/tools/split.cpp b/src/tools/split.cpp
index 5151229edd8..586264283d7 100644
--- a/src/tools/split.cpp
+++ b/src/tools/split.cpp
@@ -119,7 +119,7 @@ static int split_file(const char *filename, const char *basename, UINT32 splitsi
splitfilename.assign(basename).append(".split");
// create the split file
- filerr = util::core_file::open(splitfilename.c_str(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_NO_BOM, splitfile);
+ filerr = util::core_file::open(splitfilename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_NO_BOM, splitfile);
if (filerr != osd_file::error::NONE)
{
fprintf(stderr, "Fatal error: unable to create split file '%s'\n", splitfilename.c_str());
@@ -155,7 +155,7 @@ static int split_file(const char *filename, const char *basename, UINT32 splitsi
outfilename = string_format("%s.%03d", basename, partnum);
// create it
- filerr = util::core_file::open(outfilename.c_str(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, outfile);
+ filerr = util::core_file::open(outfilename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, outfile);
if (filerr != osd_file::error::NONE)
{
printf("\n");
@@ -267,7 +267,7 @@ static int join_file(const char *filename, const char *outname, int write_output
if (write_output)
{
// don't overwrite the original!
- filerr = util::core_file::open(outfilename.c_str(), OPEN_FLAG_READ, outfile);
+ filerr = util::core_file::open(outfilename, OPEN_FLAG_READ, outfile);
if (filerr == osd_file::error::NONE)
{
outfile.reset();
@@ -276,7 +276,7 @@ static int join_file(const char *filename, const char *outname, int write_output
}
// open the output for write
- filerr = util::core_file::open(outfilename.c_str(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, outfile);
+ filerr = util::core_file::open(outfilename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, outfile);
if (filerr != osd_file::error::NONE)
{
fprintf(stderr, "Fatal error: unable to create file '%s'\n", outfilename.c_str());
diff --git a/src/tools/src2html.cpp b/src/tools/src2html.cpp
index 9b3110a212f..38260a62879 100644
--- a/src/tools/src2html.cpp
+++ b/src/tools/src2html.cpp
@@ -517,7 +517,7 @@ static int output_file(file_type type, int srcrootlen, int dstrootlen, std::stri
// open the source file
util::core_file::ptr src;
- if (util::core_file::open(srcfile.c_str(), OPEN_FLAG_READ, src) != osd_file::error::NONE)
+ if (util::core_file::open(srcfile, OPEN_FLAG_READ, src) != osd_file::error::NONE)
{
fprintf(stderr, "Unable to read file '%s'\n", srcfile.c_str());
return 1;
@@ -732,7 +732,7 @@ static util::core_file::ptr create_file_and_output_header(std::string &filename,
{
// create the indexfile
util::core_file::ptr file;
- if (util::core_file::open(filename.c_str(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS | OPEN_FLAG_NO_BOM, file) != osd_file::error::NONE)
+ if (util::core_file::open(filename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS | OPEN_FLAG_NO_BOM, file) != osd_file::error::NONE)
return util::core_file::ptr();
// print a header
@@ -865,7 +865,7 @@ static bool find_include_file(std::string &srcincpath, int srcrootlen, int dstro
// see if we can open it
util::core_file::ptr testfile;
- if (util::core_file::open(srcincpath.c_str(), OPEN_FLAG_READ, testfile) == osd_file::error::NONE)
+ if (util::core_file::open(srcincpath, OPEN_FLAG_READ, testfile) == osd_file::error::NONE)
{
// close the file
testfile.reset();