From 61364e604469db246890e78085f26f57a3b5f4ad Mon Sep 17 00:00:00 2001 From: Christian Schlittchen Date: Wed, 27 Mar 2002 13:50:48 +0000 Subject: [PATCH] - Wird bei -v ein Directory angegeben, werden alle Dateien des Directory eingelesen. --- src/mapper/map_partei.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/src/mapper/map_partei.c b/src/mapper/map_partei.c index 454a52ddf..8ecd7bd28 100644 --- a/src/mapper/map_partei.c +++ b/src/mapper/map_partei.c @@ -40,6 +40,12 @@ #include #include +#ifdef __USE_POSIX +#include +#include +#include +#endif + const char * orderfile = NULL; void @@ -158,14 +164,15 @@ give_latestart_bonus(region *r, unit *u, int b) dropout * dropouts = NULL; void -read_orders(const char * filename) +read_orders_file(const char * filename) { faction * f = NULL; - FILE * F = fopen(filename, "r"); char * b; char buffer[16]; + FILE * F = fopen(filename, "r"); if (F==NULL) return; + b = getbuf(F); while (b) { @@ -184,6 +191,35 @@ read_orders(const char * filename) b = getbuf(F); } fclose(F); +} + +void +read_orders(const char * filename) +{ + faction *f; + +#ifdef __USE_POSIX /* if filename points to a directory, read + all files it contains. */ + struct stat statbuf; + + if(stat(filename, &statbuf)) { + if(S_ISDIR(statbuf.st_mode)) { + DIR *dir = opendir(filename); + struct dirent *d_ent; + + if(dir==NULL) return; + while((d_ent = readdir(dir)) != NULL) { + read_orders_file(d_ent->d_name); + } + closedir(dir); + } else { + read_orders_file(filename); + } + } +#else /* we do not have this functionality */ + read_orders_file(filename); +#endif + for (f=factions;f;f=f->next) { if (!fval(f, FL_MARK) && f->age <=1) { ursprung * ur = f->ursprung;