repo

List, download and sync packs with remote repositories
Log | Files | Refs

commit 268212a0aea3fae8f59c6484866fe33fab2a2638
parent 1ed45f78e709a131a34d15c47b95cd41d53ceec8
Author: z3bra <contactatz3bradotorg>
Date:   Thu Dec 15 10:59:35 +0100

Remove calls to mkdir()

Directory should be created beforhand, so it's not our job to create it.

Diffstat:
repo.c | 40----------------------------------------
1 file changed, 0 insertions(+), 40 deletions(-)
diff --git a/repo.c b/repo.c @@ -4,8 +4,6 @@ #include <stdlib.h> #include <string.h> #include <sys/queue.h> -#include <sys/stat.h> -#include <sys/types.h> #include <unistd.h> #include <curl/curl.h> @@ -25,7 +23,6 @@ struct pack { TAILQ_HEAD(packs, pack); void usage(char *); -int mkdir_parents(char *, mode_t); struct pack *pack_load(char *); int local_load(struct packs *, char *); int local_list(char *); @@ -38,30 +35,6 @@ usage(char *name) exit(1); } -/* - * Recursive mkdir, taken from the ii project - * http://nion.modprobe.de/blog/archives/357-Recursive-directory-creation.html - */ -int -mkdir_parents(char *path, mode_t mode) -{ - char tmp[PATH_MAX] = ""; - char *p = NULL; - size_t len; - - snprintf(tmp, sizeof(tmp), "%s", path); - len = strlen(tmp); - if(tmp[len - 1] == '/') - tmp[len - 1] = 0; - for(p = tmp + 1; *p; p++) - if(*p == '/') { - *p = 0; - mkdir(tmp, mode); - *p = '/'; - } - return mkdir(tmp, mode); -} - struct pack * pack_load(char *repoline) { @@ -138,25 +111,12 @@ remote_sync(char *remote, char *local, char *file) FILE *list; CURL *c; CURLcode r; - struct stat sb; - - if (stat(local, &sb) < 0) { - switch (errno) { - case ENOENT: - mkdir_parents(local, 0755); - break; - default: - perror(local); - return -1; - } - } c = curl_easy_init(); if (!c) return -1; enc = curl_easy_escape(c, file, strlen(file)); - //printf("encoded: '%s' -> '%s'\n", file, enc); len = strlen(remote) + strlen(enc); url = malloc(len + 1); if (!url) {