From: Mikko Rasa Date: Mon, 10 Nov 2014 17:47:56 +0000 (+0200) Subject: Add version of add_pack_io with filter X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=010737b64c8d4e7fcf0fe953ed15769eeac4178f;p=libs%2Fdatafile.git Add version of add_pack_io with filter --- diff --git a/source/packsource.cpp b/source/packsource.cpp index 938a627..fe9e67d 100644 --- a/source/packsource.cpp +++ b/source/packsource.cpp @@ -33,11 +33,16 @@ void PackSource::add_pack_io(IO::Seekable &io, const string &fn) add_pack(&io, fn, string()); } +void PackSource::add_pack_io(IO::Seekable &io, const string &fn, const string &filter) +{ + add_pack(&io, fn, filter); +} + void PackSource::add_pack(IO::Seekable *io, const string &fn, const string &filter) { Pack *pack = 0; for(list::iterator i=packs.begin(); (!pack && i!=packs.end()); ++i) - if(i->get_filename()==fn) + if(i->get_filename()==fn || (io && i->get_io()==io)) pack = &*i; if(!pack) { diff --git a/source/packsource.h b/source/packsource.h index 440b451..7d61661 100644 --- a/source/packsource.h +++ b/source/packsource.h @@ -130,6 +130,10 @@ public: PackSource. */ void add_pack_io(IO::Seekable &, const std::string & = std::string()); + /** Adds a pack from an I/O object with a regex to filter logical files. + Multiple filters for the same I/O object can be added with repeated calls. */ + void add_pack_io(IO::Seekable &, const std::string &, const std::string &); + private: void add_pack(IO::Seekable *, const std::string &, const std::string &);