made it so including a directory in WML will recurse into subdirs.

Made WML support '~' notation to include files in ~/.wesnoth/data
This commit is contained in:
Dave White 2004-05-24 15:42:43 +00:00
parent f31c209d18
commit 1c23e287a9
6 changed files with 18 additions and 9 deletions

View file

@ -14,6 +14,9 @@
{terrain_generator.cfg}
{~scenarios}
{~units}
[game_config]
base_income=2
village_income=1

View file

@ -1 +0,0 @@
{scenarios/Heir_To_The_Throne}

View file

@ -1 +0,0 @@
{scenarios/Son_Of_The_Black_Eye}

View file

@ -1 +0,0 @@
{scenarios/The_Dark_Hordes}

View file

@ -288,7 +288,16 @@ void internal_preprocess_data(const std::string& data,
internal_preprocess_data(str,defines_map,depth,res,NULL,line,fname,srcline);
} else if(depth < 20) {
internal_preprocess_file("data/" + newfilename,
std::string prefix;
std::string fname = newfilename;
//if the filename begins with a '~', then look in the user's data directory
if(newfilename != "" && fname[0] == '~') {
prefix = get_user_data_dir() + "/";
fname.erase(fname.begin(),fname.begin()+1);
}
internal_preprocess_file(prefix + "data/" + fname,
defines_map, depth+1,res,
lines_src,line);
} else {
@ -426,13 +435,12 @@ void internal_preprocess_file(const std::string& fname,
if(is_directory(fname)) {
std::vector<std::string> files;
get_files_in_dir(fname,&files,NULL,ENTIRE_FILE_PATH);
get_files_in_dir(fname,&files,&files,ENTIRE_FILE_PATH);
for(std::vector<std::string>::const_iterator f = files.begin();
f != files.end(); ++f) {
if(is_directory(*f) || (f->size() > 4 && std::equal(f->end()-4,f->end(),".cfg"))) {
internal_preprocess_file(*f,defines_map,depth,res,
lines_src,line);
if(is_directory(*f) || f->size() > 4 && std::equal(f->end()-4,f->end(),".cfg")) {
internal_preprocess_file(*f,defines_map,depth,res,lines_src,line);
}
}

View file

@ -46,6 +46,7 @@
#include "filesystem.hpp"
#include "game_config.hpp"
#include "util.hpp"
namespace {
const mode_t AccessMode = 00770;
@ -300,7 +301,7 @@ time_t data_tree_modified_time()
{
static time_t cached_val = 0;
if(cached_val == 0) {
cached_val = file_tree_modified_time("data/");
cached_val = maximum<time_t>(file_tree_modified_time("data/"),file_tree_modified_time(get_user_data_dir() + "/data"));
}
return cached_val;