From c5ecc24402f73daf1d1f688aa3e8d3d0356651be Mon Sep 17 00:00:00 2001 From: tomo Date: Mon, 6 Oct 2003 02:37:07 +0000 Subject: [PATCH] (CHISE_Attribute_Table_open): Create required directories when running with create mode. --- chise.c | 11 +++++++++++ 1 file changed, 11 insertions(+) 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)]; -- 1.7.10.4