mirror of
https://github.com/holub/mame
synced 2025-06-25 13:54:37 +03:00
Better performance for -verifyroms on samba share [qmc2]
This commit is contained in:
parent
4a99009812
commit
be88bed238
@ -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()))
|
||||
|
@ -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, "/");
|
||||
|
@ -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
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user