diff --git a/fsops.c b/fsops.c index 5656350..362c695 100644 --- a/fsops.c +++ b/fsops.c @@ -102,9 +102,14 @@ void create_dirs() { /* create database repository */ - mkdir(PKGIN_DB, 0755); + if(-1 == mkdir(PKGIN_DB, 0755)) + errx(EXIT_FAILURE, MSG_MKDIR_DB_REPOSITORY_FAILED, + strerror(errno)); // look errno /* create cache repository */ - mkdir(pkgin_cache, 0755); + if(-1 == mkdir(pkgin_cache, 0755)) + errx(EXIT_FAILURE, MSG_MKDIR_CACHE_REPOSITORY_FAILED, + strerror(errno)); + } char * diff --git a/messages.h b/messages.h index ba1846f..bffb3c3 100644 --- a/messages.h +++ b/messages.h @@ -153,6 +153,8 @@ please re-run %s with a package name matching one of the following:\n" /* fsops.c */ #define MSG_TRANS_FAILED "Failed to translate %s in repository config file" #define MSG_INVALID_REPOS "Invalid repository: %s" +#define MSG_MKDIR_DB_REPOSITORY_FAILED "Failed to create database repository %s\n" +#define MSG_MKDIR_CACHE_REPOSITORY_FAILED "Failed to create cache repository %s\n" /* selection.c */ #define MSG_EMPTY_IMPORT_LIST "Empty import list."