]> git.tdb.fi Git - libs/game.git/blobdiff - source/game/resources.cpp
Recursively add subdirectories of the data directory to resources
[libs/game.git] / source / game / resources.cpp
index 0893f97525c564b6b5356e1fda5c420b309fbcc9..2b186de952049cb5ef504267775a6e0df191f96c 100644 (file)
@@ -12,7 +12,7 @@ ApplicationResources::ApplicationResources()
        FS::Path data_dir = FS::get_sys_data_dir()/"data";
 #ifdef DEBUG
        if(FS::exists(data_dir))
-               dir_src.add_directory(data_dir);
+               add_dir(data_dir);
        add_source(dir_src);
 #endif
 
@@ -27,4 +27,15 @@ ApplicationResources::ApplicationResources()
        add_source(pack_src);
 }
 
+void ApplicationResources::add_dir(const FS::Path &path)
+{
+       dir_src.add_directory(path);
+       for(const string &f: FS::list_files(path))
+       {
+               FS::Path p = path/f;
+               if(FS::is_dir(p))
+                       add_dir(p);
+       }
+}
+
 } // namespace Msp::Game