diff options
author | 2016-03-13 13:54:57 +1100 | |
---|---|---|
committer | 2016-03-14 18:55:00 +1100 | |
commit | 42fbb9c3967fcda37f2d9ae17d5796a79cf027b9 (patch) | |
tree | a43047ee00431e5e22bfc5f8f612ff775586e415 /src/tools/romcmp.cpp | |
parent | 5fc27747031b6ed6f6c0582502098ebfb960be67 (diff) |
Make osd_file a polymorphic class that's held with smart pointers
Make avi_file a class that's held with smart pointers, encapsulate various AVI I/O structures
Make zip_file and _7z_file classes rather than having free functions everywhere
Hide zip/7z class implementation behind an interface, no longer need to call close() to send back to the cache
Don't dump as much crap in global namespace
Add solaris PTY implementation
Improve variable expansion for SDL OSD - supports ~/$FOO/${BAR} syntax
Rearrange stuff so the same things are in file module for all OSDs
Move file stuff into its own module
7z/zip open and destruct are still not thread-safe due to lack of interlocks around cache access
Directory functions still need to be moved to file module
SDL OSD may not initialise WinSock on Windows
Diffstat (limited to 'src/tools/romcmp.cpp')
-rw-r--r-- | src/tools/romcmp.cpp | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/src/tools/romcmp.cpp b/src/tools/romcmp.cpp index 4d89718abe9..a6919631cd8 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,20 +490,20 @@ 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; + zip_file::ptr zip; + const zip_file::file_header* zipent; + zip_file::error ziperr; /* wasn't a directory, so try to open it as a zip file */ - ziperr = zip_file_open(path, &zip); - if (ziperr != ZIPERR_NONE) + ziperr = zip_file::open(path, zip); + if (ziperr != zip_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 (zipent = zip->first_file(); zipent != nullptr; zipent = zip->next_file()) { int size; @@ -529,7 +526,7 @@ static int load_files(int i, int *found, const char *path) 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) != zip_file::error::NONE) { free(file->buf); file->buf = nullptr; @@ -545,7 +542,6 @@ static int load_files(int i, int *found, const char *path) found[i]++; } } - zip_file_close(zip); } return 0; } @@ -747,6 +743,6 @@ int CLIB_DECL main(int argc,char *argv[]) } } - zip_file_cache_clear(); + zip_file::cache_clear(); return 0; } |