pm

barely a pack manager
git clone git://z3bra.org/pm
Log | Files | Refs | README | LICENSE

commit 84b7654d682411377a6469d7bb79a4aca45a4039
parent 4ea0aa4f385ef8dd95a6747669676f4cee1ab402
Author: z3bra <willyatmailoodotorg>
Date:   Wed Dec 23 13:18:08 2015

Check if datadir exist before creating it

Diffstat:
 pm.c |  9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/pm.c b/pm.c @@ -96,14 +96,17 @@ int metadata(const char *datadir, const char *filename) { int fd, r; + struct stat st; char tmp[PATH_MAX]; strncpy(tmp, datadir, PATH_MAX); strncat(tmp, "/files", PATH_MAX); - r = mkdir(datadir, 0750); - if (r < 0) - return r; + if (stat(datadir, &st) < 0) { + r = mkdir(datadir, 0750); + if (r < 0) + return r; + } fd = open(tmp, O_CREAT|O_WRONLY|O_TRUNC, 0644);