diff options
author | Vas Crabb <vas@vastheman.com> | 2016-08-19 15:23:31 +1000 |
---|---|---|
committer | Vas Crabb <vas@vastheman.com> | 2016-08-19 15:23:31 +1000 |
commit | 563690f545e59121c3c3e17a306b7b791ef1dc6e (patch) | |
tree | 78913a6f0e4513fb032632a5eecff541f21fa3b5 /src/emu/fileio.h | |
parent | 2a705f54e7c8d6d57cfebdcac3b0e57bedb4703b (diff) |
make path_iterator hold onto its search path
Diffstat (limited to 'src/emu/fileio.h')
-rw-r--r-- | src/emu/fileio.h | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/src/emu/fileio.h b/src/emu/fileio.h index 69479bc5a98..218821f7aa5 100644 --- a/src/emu/fileio.h +++ b/src/emu/fileio.h @@ -34,20 +34,25 @@ namespace util { class archive_file; } class path_iterator { public: - // construction/destruction - path_iterator(const char *searchpath); + // constructors + path_iterator(std::string &&searchpath); + path_iterator(std::string const &searchpath); + path_iterator(path_iterator &&that); + path_iterator(path_iterator const &that); - // getters - bool next(std::string &buffer, const char *name = nullptr); + // assignment operators + path_iterator &operator=(path_iterator &&that); + path_iterator &operator=(path_iterator const &that); - // reset - void reset() { m_current = m_base; m_index = 0; } + // main interface + bool next(std::string &buffer, const char *name = nullptr); + void reset(); private: // internal state - const char * m_base; - const char * m_current; - int m_index; + std::string m_searchpath; + std::string::const_iterator m_current; + bool m_is_first; }; @@ -59,8 +64,11 @@ class file_enumerator { public: // construction/destruction - file_enumerator(const char *searchpath); - ~file_enumerator(); + template <typename... T> file_enumerator(T &&... args) : m_iterator(std::forward<T>(args)...) { } + file_enumerator(file_enumerator &&) = default; + file_enumerator(file_enumerator const &) = delete; + file_enumerator &operator=(file_enumerator &&) = default; + file_enumerator &operator=(file_enumerator const &) = delete; // iterator const osd::directory::entry *next(); @@ -70,7 +78,6 @@ private: path_iterator m_iterator; osd::directory::ptr m_curdir; std::string m_pathbuffer; - //int m_buflen; }; @@ -82,7 +89,7 @@ class emu_file public: // file open/creation emu_file(UINT32 openflags); - emu_file(const char *searchpath, UINT32 openflags); + emu_file(std::string &&searchpath, UINT32 openflags); virtual ~emu_file(); // getters @@ -155,7 +162,7 @@ private: path_iterator m_mediapaths; // media-path iterator UINT32 m_crc; // file's CRC UINT32 m_openflags; // flags we used for the open - util::hash_collection m_hashes; // collection of hashes + util::hash_collection m_hashes; // collection of hashes std::unique_ptr<util::archive_file> m_zipfile; // ZIP file pointer dynamic_buffer m_zipdata; // ZIP file data |