]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/directorysource.cpp
Move the definition of Input's operator bool to the header
[libs/datafile.git] / source / directorysource.cpp
index 207f30d0e31716c310f0927b82f5ba14fe456b6a..7e1e438a2a49ab1ed87996ca87b806eb3e8dc18e 100644 (file)
@@ -10,12 +10,9 @@ namespace DataFile {
 
 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)
-       {
-               if(!objects.count(*i) || replace)
-                       objects[*i] = d / *i;
-       }
+       for(const string &f: FS::list_files(d))
+               if(!objects.count(f) || replace)
+                       objects[f] = d/f;
 }
 
 bool DirectorySource::is_loadable(const CollectionItemTypeBase &, const string &name) const
@@ -26,9 +23,9 @@ bool DirectorySource::is_loadable(const CollectionItemTypeBase &, const string &
 CollectionSource::NameList DirectorySource::get_names(const CollectionItemTypeBase &type) const
 {
        NameList names;
-       for(ObjectMap::const_iterator i=objects.begin(); i!=objects.end(); ++i)
-               if(type.match_name(i->first))
-                       names.push_back(i->first);
+       for(const auto &kvp: objects)
+               if(type.match_name(kvp.first))
+                       names.push_back(kvp.first);
        return names;
 }
 
@@ -49,7 +46,7 @@ IO::Seekable *DirectorySource::open(const string &name) const
        if(lookup_file(name, file))
                return new IO::BufferedFile(file.str());
 
-       return 0;
+       return nullptr;
 }
 
 bool DirectorySource::lookup_file(const string &name, FS::Path &result) const