From: tomo Date: Mon, 6 Oct 2003 02:37:07 +0000 (+0000) Subject: (CHISE_Attribute_Table_open): Create required directories when running X-Git-Tag: b1-r0_2_0-pre7~4 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c5ecc24402f73daf1d1f688aa3e8d3d0356651be;p=chise%2Flibchise.git (CHISE_Attribute_Table_open): Create required directories when running with create mode. --- diff --git a/chise.c b/chise.c index 04678c8..da12d1b 100644 --- a/chise.c +++ b/chise.c @@ -1,4 +1,7 @@ #include +#include +#include +#include #ifdef HAVE_CONFIG_H # include "config.h" #endif @@ -497,11 +500,15 @@ CHISE_Attribute_Table_open (const unsigned char *db_dir, int len, flen, i; int size; char *db_file_name, *sp; + struct stat statbuf; status = db_create (&dbase, NULL, 0); if (status) return NULL; + if ( (accessmask & DB_CREATE) && stat (db_dir, &statbuf) ) + mkdir (db_dir, modemask); + len = strlen (db_dir); flen = strlen (feature); size = len + strlen (encoding) + flen * 3 + 4; @@ -513,6 +520,10 @@ CHISE_Attribute_Table_open (const unsigned char *db_dir, db_file_name[len] = '\0'; } strcat (db_file_name, encoding); + + if ( (accessmask & DB_CREATE) && stat (db_file_name, &statbuf) ) + mkdir (db_file_name, modemask); + strcat (db_file_name, "/"); /* strcat (db_file_name, feature); */ sp = &db_file_name[strlen (db_file_name)];