- insert_unique(objects, object.get_article_number(), &object);
- signal_object_added.emit(object);
-}
-
-const ObjectType &Catalogue::get(const ArticleNumber &art_nr) const
-{
- return *get_item(objects, art_nr);
+ string ext = FS::extpart(path.str());
+ DataFile::CollectionSource *source = 0;
+ IO::Seekable *init_file = 0;
+ if(ext==".mdt")
+ {
+ DataFile::PackSource *pack_source = new DataFile::PackSource;
+ pack_source->add_pack_file(path.str());
+ source = pack_source;
+
+ list<DataFile::PackSource::FileInfo> files = pack_source->list_files();
+ for(list<DataFile::PackSource::FileInfo>::const_iterator i=files.begin(); i!=files.end(); ++i)
+ {
+ string fext = FS::extpart(i->name);
+ if(fext==".cat" && !init_file)
+ init_file = pack_source->open(i->name);
+ }
+ }
+ else if(FS::is_dir(path))
+ {
+ DataFile::DirectorySource *dir_source = new DataFile::DirectorySource;
+ dir_source->add_directory(path);
+
+ list<FS::Path> queue;
+ queue.push_back(path);
+ while(!queue.empty())
+ {
+ FS::Path dir = queue.front();
+ queue.pop_front();
+ list<string> files = FS::list_files(dir);
+ for(list<string>::const_iterator i=files.begin(); i!=files.end(); ++i)
+ {
+ FS::Path full = dir/ *i;
+ if(FS::is_dir(full))
+ {
+ dir_source->add_directory(full);
+ queue.push_back(full);
+ }
+
+ string fext = FS::extpart(*i);
+ if(fext==".cat" && !init_file)
+ init_file = new IO::BufferedFile(full.str());
+ }
+ }
+
+ source = dir_source;
+ }
+
+ sources.push_back(source);
+ Collection::add_source(*source);
+ signal_source_added.emit(*source);
+
+ if(init_file)
+ {
+ DataFile::Parser parser(*init_file, path.str());
+ Loader ldr(*this);
+ ldr.load(parser);
+ }
+ delete init_file;