diff options
author | 2015-02-12 18:36:34 +0100 | |
---|---|---|
committer | 2015-02-12 18:36:34 +0100 | |
commit | be88bed2384951aae8c1f9bff51c74fbc0ce128f (patch) | |
tree | e67c2c14a195f74a7dcc40a31b8a959a60440532 | |
parent | 4a99009812bf107c7937302ca3f45ce42f69159b (diff) |
Better performance for -verifyroms on samba share [qmc2]
-rw-r--r-- | src/emu/audit.c | 1 | ||||
-rw-r--r-- | src/emu/fileio.c | 37 | ||||
-rw-r--r-- | src/emu/fileio.h | 7 |
3 files changed, 38 insertions, 7 deletions
diff --git a/src/emu/audit.c b/src/emu/audit.c index e02ddbcc77b..8de307d0728 100644 --- a/src/emu/audit.c +++ b/src/emu/audit.c @@ -421,6 +421,7 @@ audit_record *media_auditor::audit_one_rom(const rom_entry *rom) // find the file and checksum it, getting the file length along the way emu_file file(m_enumerator.options().media_path(), OPEN_FLAG_READ | OPEN_FLAG_NO_PRELOAD); + file.set_restrict_to_mediapath(true); path_iterator path(m_searchpath); astring curpath; while (path.next(curpath, record.name())) diff --git a/src/emu/fileio.c b/src/emu/fileio.c index 4883c199d4a..cc4ff44ff2a 100644 --- a/src/emu/fileio.c +++ b/src/emu/fileio.c @@ -141,13 +141,15 @@ const osd_directory_entry *file_enumerator::next() emu_file::emu_file(UINT32 openflags) : m_file(NULL), m_iterator(""), + m_mediapaths(""), m_crc(0), m_openflags(openflags), m_zipfile(NULL), m_ziplength(0), m__7zfile(NULL), m__7zlength(0), - m_remove_on_close(false) + m_remove_on_close(false), + m_restrict_to_mediapath(false) { // sanity check the open flags if ((m_openflags & OPEN_FLAG_HAS_CRC) && (m_openflags & OPEN_FLAG_WRITE)) @@ -157,13 +159,15 @@ emu_file::emu_file(UINT32 openflags) emu_file::emu_file(const char *searchpath, UINT32 openflags) : m_file(NULL), m_iterator(searchpath), + m_mediapaths(searchpath), m_crc(0), m_openflags(openflags), m_zipfile(NULL), m_ziplength(0), m__7zfile(NULL), m__7zlength(0), - m_remove_on_close(false) + m_remove_on_close(false), + m_restrict_to_mediapath(false) { // sanity check the open flags if ((m_openflags & OPEN_FLAG_HAS_CRC) && (m_openflags & OPEN_FLAG_WRITE)) @@ -354,17 +358,15 @@ file_error emu_file::open_next() { astring tempfullpath = m_fullpath; - filerr = attempt__7zped(); + filerr = attempt_zipped(); if (filerr == FILERR_NONE) break; m_fullpath = tempfullpath; - filerr = attempt_zipped(); + filerr = attempt__7zped(); if (filerr == FILERR_NONE) break; - - } } return filerr; @@ -650,6 +652,21 @@ int emu_file::vprintf(const char *fmt, va_list va) } +//------------------------------------------------- +// part_of_mediapath - checks if 'path' is part of +// any media path +//------------------------------------------------- + +bool emu_file::part_of_mediapath(astring path) +{ + bool result = false; + astring mediapath; + m_mediapaths.reset(); + while (m_mediapaths.next(mediapath, NULL) && !result) + if (path.cmpsubstr(mediapath, 0, mediapath.len())) + result = true; + return result; +} //------------------------------------------------- // attempt_zipped - attempt to open a ZIPped file @@ -667,6 +684,10 @@ file_error emu_file::attempt_zipped() if (dirsep == -1) return FILERR_NOT_FOUND; + if (restrict_to_mediapath()) + if ( !part_of_mediapath(m_fullpath) ) + return FILERR_NOT_FOUND; + // insert the part from the right of the separator into the head of the filename if (filename.len() > 0) filename.ins(0, "/"); @@ -798,6 +819,10 @@ file_error emu_file::attempt__7zped() if (dirsep == -1) return FILERR_NOT_FOUND; + if (restrict_to_mediapath()) + if ( !part_of_mediapath(m_fullpath) ) + return FILERR_NOT_FOUND; + // insert the part from the right of the separator into the head of the filename if (filename.len() > 0) filename.ins(0, "/"); diff --git a/src/emu/fileio.h b/src/emu/fileio.h index b5781a5d1c3..5b2c4d7948c 100644 --- a/src/emu/fileio.h +++ b/src/emu/fileio.h @@ -97,10 +97,13 @@ public: const char *fullpath() const { return m_fullpath; } UINT32 openflags() const { return m_openflags; } hash_collection &hashes(const char *types); + bool restrict_to_mediapath() { return m_restrict_to_mediapath; } + bool part_of_mediapath(astring path); // setters void remove_on_close() { m_remove_on_close = true; } void set_openflags(UINT32 openflags) { assert(m_file == NULL); m_openflags = openflags; } + void set_restrict_to_mediapath(bool rtmp = true) { m_restrict_to_mediapath = rtmp; } // open/close file_error open(const char *name); @@ -151,7 +154,8 @@ private: astring m_fullpath; // full filename core_file * m_file; // core file pointer path_iterator m_iterator; // iterator for paths - UINT32 m_crc; // iterator for paths + path_iterator m_mediapaths; // media-path iterator + UINT32 m_crc; // file's CRC UINT32 m_openflags; // flags we used for the open hash_collection m_hashes; // collection of hashes @@ -164,6 +168,7 @@ private: UINT64 m__7zlength; // 7Z file length bool m_remove_on_close; // flag: remove the file when closing + bool m_restrict_to_mediapath; // flag: restrict to paths inside the media-path }; |