- Wird bei -v ein Directory angegeben, werden alle Dateien des Directory

eingelesen.
This commit is contained in:
Christian Schlittchen 2002-03-27 13:50:48 +00:00
parent c3eb994051
commit 61364e6044
1 changed files with 38 additions and 2 deletions

View File

@ -40,6 +40,12 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#ifdef __USE_POSIX
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#endif
const char * orderfile = NULL; const char * orderfile = NULL;
void void
@ -158,14 +164,15 @@ give_latestart_bonus(region *r, unit *u, int b)
dropout * dropouts = NULL; dropout * dropouts = NULL;
void void
read_orders(const char * filename) read_orders_file(const char * filename)
{ {
faction * f = NULL; faction * f = NULL;
FILE * F = fopen(filename, "r");
char * b; char * b;
char buffer[16]; char buffer[16];
FILE * F = fopen(filename, "r");
if (F==NULL) return; if (F==NULL) return;
b = getbuf(F); b = getbuf(F);
while (b) { while (b) {
@ -184,6 +191,35 @@ read_orders(const char * filename)
b = getbuf(F); b = getbuf(F);
} }
fclose(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) { for (f=factions;f;f=f->next) {
if (!fval(f, FL_MARK) && f->age <=1) { if (!fval(f, FL_MARK) && f->age <=1) {
ursprung * ur = f->ursprung; ursprung * ur = f->ursprung;