X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdirectorysource.cpp;h=7e1e438a2a49ab1ed87996ca87b806eb3e8dc18e;hb=refs%2Fheads%2Fwip;hp=207f30d0e31716c310f0927b82f5ba14fe456b6a;hpb=f38a2720fce4647b727030421e70fce6a28c9bd9;p=libs%2Fdatafile.git diff --git a/source/directorysource.cpp b/source/directorysource.cpp index 207f30d..7e1e438 100644 --- a/source/directorysource.cpp +++ b/source/directorysource.cpp @@ -10,12 +10,9 @@ namespace DataFile { void DirectorySource::add_directory(const FS::Path &d, bool replace) { - list files = FS::list_files(d); - for(list::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