Previous 199869 Revisions Next

r34984 Thursday 12th February, 2015 at 17:36:34 UTC by Miodrag Milanović
Better performance for -verifyroms on samba share [qmc2]
[src/emu]audit.c fileio.c fileio.h

trunk/src/emu/audit.c
r243495r243496
421421
422422   // find the file and checksum it, getting the file length along the way
423423   emu_file file(m_enumerator.options().media_path(), OPEN_FLAG_READ | OPEN_FLAG_NO_PRELOAD);
424   file.set_restrict_to_mediapath(true);
424425   path_iterator path(m_searchpath);
425426   astring curpath;
426427   while (path.next(curpath, record.name()))
trunk/src/emu/fileio.c
r243495r243496
141141emu_file::emu_file(UINT32 openflags)
142142   : m_file(NULL),
143143      m_iterator(""),
144      m_mediapaths(""),
144145      m_crc(0),
145146      m_openflags(openflags),
146147      m_zipfile(NULL),
147148      m_ziplength(0),
148149      m__7zfile(NULL),
149150      m__7zlength(0),
150      m_remove_on_close(false)
151      m_remove_on_close(false),
152      m_restrict_to_mediapath(false)
151153{
152154   // sanity check the open flags
153155   if ((m_openflags & OPEN_FLAG_HAS_CRC) && (m_openflags & OPEN_FLAG_WRITE))
r243495r243496
157159emu_file::emu_file(const char *searchpath, UINT32 openflags)
158160   : m_file(NULL),
159161      m_iterator(searchpath),
162      m_mediapaths(searchpath),
160163      m_crc(0),
161164      m_openflags(openflags),
162165      m_zipfile(NULL),
163166      m_ziplength(0),
164167      m__7zfile(NULL),
165168      m__7zlength(0),
166      m_remove_on_close(false)
169      m_remove_on_close(false),
170      m_restrict_to_mediapath(false)
167171{
168172   // sanity check the open flags
169173   if ((m_openflags & OPEN_FLAG_HAS_CRC) && (m_openflags & OPEN_FLAG_WRITE))
r243495r243496
354358      {
355359         astring tempfullpath = m_fullpath;
356360
357         filerr = attempt__7zped();
361         filerr = attempt_zipped();
358362         if (filerr == FILERR_NONE)
359363            break;
360364
361365         m_fullpath = tempfullpath;
362366
363         filerr = attempt_zipped();
367         filerr = attempt__7zped();
364368         if (filerr == FILERR_NONE)
365369            break;
366
367
368370      }
369371   }
370372   return filerr;
r243495r243496
650652}
651653
652654
655//-------------------------------------------------
656//  part_of_mediapath - checks if 'path' is part of
657//  any media path
658//-------------------------------------------------
653659
660bool emu_file::part_of_mediapath(astring path)
661{
662   bool result = false;
663   astring mediapath;
664   m_mediapaths.reset();
665   while (m_mediapaths.next(mediapath, NULL) && !result)
666      if (path.cmpsubstr(mediapath, 0, mediapath.len()))
667         result = true;
668   return result;
669}
670
654671//-------------------------------------------------
655672//  attempt_zipped - attempt to open a ZIPped file
656673//-------------------------------------------------
r243495r243496
667684      if (dirsep == -1)
668685         return FILERR_NOT_FOUND;
669686
687      if (restrict_to_mediapath())
688         if ( !part_of_mediapath(m_fullpath) )
689            return FILERR_NOT_FOUND;
690
670691      // insert the part from the right of the separator into the head of the filename
671692      if (filename.len() > 0)
672693         filename.ins(0, "/");
r243495r243496
798819      if (dirsep == -1)
799820         return FILERR_NOT_FOUND;
800821
822      if (restrict_to_mediapath())
823         if ( !part_of_mediapath(m_fullpath) )
824            return FILERR_NOT_FOUND;
825
801826      // insert the part from the right of the separator into the head of the filename
802827      if (filename.len() > 0)
803828         filename.ins(0, "/");
trunk/src/emu/fileio.h
r243495r243496
9797   const char *fullpath() const { return m_fullpath; }
9898   UINT32 openflags() const { return m_openflags; }
9999   hash_collection &hashes(const char *types);
100   bool restrict_to_mediapath() { return m_restrict_to_mediapath; }
101   bool part_of_mediapath(astring path);
100102
101103   // setters
102104   void remove_on_close() { m_remove_on_close = true; }
103105   void set_openflags(UINT32 openflags) { assert(m_file == NULL); m_openflags = openflags; }
106   void set_restrict_to_mediapath(bool rtmp = true) { m_restrict_to_mediapath = rtmp; }
104107
105108   // open/close
106109   file_error open(const char *name);
r243495r243496
151154   astring         m_fullpath;                     // full filename
152155   core_file *     m_file;                         // core file pointer
153156   path_iterator   m_iterator;                     // iterator for paths
154   UINT32          m_crc;                          // iterator for paths
157   path_iterator   m_mediapaths;         // media-path iterator
158   UINT32          m_crc;                          // file's CRC
155159   UINT32          m_openflags;                    // flags we used for the open
156160   hash_collection m_hashes;                       // collection of hashes
157161
r243495r243496
164168   UINT64          m__7zlength;                    // 7Z file length
165169
166170   bool            m_remove_on_close;              // flag: remove the file when closing
171   bool      m_restrict_to_mediapath;   // flag: restrict to paths inside the media-path
167172};
168173
169174


Previous 199869 Revisions Next


© 1997-2024 The MAME Team