Skip to content

Commit

Permalink
Revert "Merge branch 'bee-dep-fixes'"
Browse files Browse the repository at this point in the history
This reverts commit ca5370a, reversing
changes made to 2f2c48c.
  • Loading branch information
mariux committed Dec 19, 2011
1 parent 1aab47b commit f3cd517
Showing 1 changed file with 22 additions and 30 deletions.
52 changes: 22 additions & 30 deletions src/bee-dep.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
#include <libgen.h>
#include <unistd.h>
#include <getopt.h>
#include <errno.h>
#include <assert.h>

#include "graph.h"

Expand Down Expand Up @@ -159,45 +157,32 @@ static FILE *open_and_lock(char *filename, char *mode)
return f;
}

/* create all directories in path with mode mode */
int mkdirp(char *path, mode_t mode)
{
char *dir, *pdir, *end;
int ret;

assert(path);

dir = end = path;

while(*dir) {
/* skip "/" */
dir = end + strspn(end, "/");

/* skip non-"/" */
end = dir + strcspn(dir, "/");

/* grab everything in path till current end */
if(!(pdir = strndup(path, end - path)))
return -1;
char *dir, *pdir;
struct stat st;

/* create the directory ; ignore err if it already exists */
ret = mkdir(pdir, mode);
if(path == NULL) {
return -1;
}

free(pdir);
dir = strdup(path);
pdir = dirname(dir);
if(stat(pdir, &st) == -1) {
mkdirp(pdir, mode);
}

if(ret == -1 && errno != EEXIST)
return -1;
}
free(dir);

return 0;
return mkdir(path, mode);
}

int main(int argc, char *argv[])
{
int c, help, rebuild, update, remove, print, options;
char found;
char cachefile[PATH_MAX + 1], path[PATH_MAX + 1], tmp[PATH_MAX + 1];
char *bee_metadir, *bee_cachedir, *pkgname;
char *bee_metadir, *bee_cachedir, *dir, *pkgname;
struct hash *graph;
struct stat st;
FILE *cache;
Expand Down Expand Up @@ -272,11 +257,18 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}

if (mkdirp(bee_cachedir, 0755) == -1) {
perror("bee-dep: mkdirp");
dir = strdup(cachefile);
dir = dirname(dir);

if (stat(dir, &st) == -1 && mkdirp(dir, 0755) == -1) {
perror("bee-dep: mkdir");
exit(EXIT_FAILURE);
}

free(dir);

graph = NULL;

found = (stat(cachefile, &st) != -1 && S_ISREG(st.st_mode));

graph = hash_new();
Expand Down

0 comments on commit f3cd517

Please sign in to comment.