]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/collection.cpp
Add an API to open files from a collection's sources
[libs/datafile.git] / source / collection.cpp
index 070991948d33d7315074ec6bb480cc06344d45cc..984fb74da8e7a6007645e6f85aa002b8ae6f894a 100644 (file)
@@ -91,6 +91,15 @@ void Collection::add_source(CollectionSource &s)
        sources.push_back(&s);
 }
 
+IO::Seekable *Collection::open_from_sources(const string &name)
+{
+       for(SourceList::const_iterator i=sources.begin(); i!=sources.end(); ++i)
+               if(IO::Seekable *io = (*i)->open(name))
+                       return io;
+
+       throw IO::file_not_found(name);
+}
+
 void Collection::gather_names_from_sources(list<string> &names, const CollectionItemTypeBase &type) const
 {
        for(SourceList::const_iterator i=sources.begin(); i!=sources.end(); ++i)