index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Aurelien Foret <aurelien@archlinux.org> | 2006-02-16 21:02:39 +0000 |
---|---|---|
committer | Aurelien Foret <aurelien@archlinux.org> | 2006-02-16 21:02:39 +0000 |
commit | 58a7e85534f260a49a324dd5b3f408ce1e21cd18 (patch) | |
tree | f0b60c1c8a26a58400522ceee54fb908866a64a0 /lib/libalpm/alpm.c | |
parent | dc0bacf18cfe2481516778905051879bd008f517 (diff) |
-rw-r--r-- | lib/libalpm/alpm.c | 12 |
diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c index 58474eb8..7ac7ada2 100644 --- a/lib/libalpm/alpm.c +++ b/lib/libalpm/alpm.c @@ -161,6 +161,8 @@ int alpm_get_option(unsigned char parm, long *data) */ pmdb_t *alpm_db_register(char *treename) { + char path[PATH_MAX]; + struct stat buf; pmdb_t *db; int found = 0; @@ -187,7 +189,15 @@ pmdb_t *alpm_db_register(char *treename) RET_ERR(PM_ERR_DB_NOT_NULL, NULL); } - db = db_open(handle->root, handle->dbpath, treename, DB_O_CREATE); + /* make sure the database directory exists */ + snprintf(path, PATH_MAX, "%s%s", handle->root, handle->dbpath); + if(stat(path, &buf) != 0 || !S_ISDIR(buf.st_mode)) { + if(_alpm_makepath(path) != 0) { + RET_ERR(PM_ERR_SYSTEM, NULL); + } + } + + db = db_open(path, treename, DB_O_CREATE); if(db == NULL) { RET_ERR(PM_ERR_DB_OPEN, NULL); } |