]> git.tdb.fi Git - libs/datafile.git/commitdiff
Add a flag to control replacement of DirectorySource entries
authorMikko Rasa <tdb@tdb.fi>
Sun, 5 Oct 2014 01:50:48 +0000 (04:50 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 5 Oct 2014 01:50:48 +0000 (04:50 +0300)
source/directorysource.cpp
source/directorysource.h

index 4bf9f5cd3d12b0808f288b9e3cd647a5ee0db682..207f30d0e31716c310f0927b82f5ba14fe456b6a 100644 (file)
@@ -8,11 +8,14 @@ using namespace std;
 namespace Msp {
 namespace DataFile {
 
-void DirectorySource::add_directory(const FS::Path &d)
+void DirectorySource::add_directory(const FS::Path &d, bool replace)
 {
        list<string> files = FS::list_files(d);
        for(list<string>::const_iterator i=files.begin(); i!=files.end(); ++i)
-               objects[*i] = d / *i;
+       {
+               if(!objects.count(*i) || replace)
+                       objects[*i] = d / *i;
+       }
 }
 
 bool DirectorySource::is_loadable(const CollectionItemTypeBase &, const string &name) const
index b1324a711d2ac6c7f8e489215589c39fc87b62f8..660d4e823fab6364ada247dff9a9518d0a04dcfa 100644 (file)
@@ -18,7 +18,7 @@ private:
        ObjectMap objects;
 
 public:
-       void add_directory(const FS::Path &);
+       void add_directory(const FS::Path &, bool = true);
 
        virtual bool is_loadable(const CollectionItemTypeBase &, const std::string &) const;
        virtual NameList get_names(const CollectionItemTypeBase &) const;