aboutsummaryrefslogtreecommitdiffstats
path: root/src/redo.c
diff options
context:
space:
mode:
authorTharre <tharre3@gmail.com>2014-08-14 18:19:15 +0200
committerTharre <tharre3@gmail.com>2014-08-14 18:19:15 +0200
commitb2a3f4f62375f2571725075c2622b8bf4e555b80 (patch)
tree6e303c2b3a658c800610b5b41707bbf50fc62cd6 /src/redo.c
parentc5367b4f3a706fd3c638fb8ae260f88970c0a741 (diff)
downloadredo-b2a3f4f62375f2571725075c2622b8bf4e555b80.tar.gz
redo-b2a3f4f62375f2571725075c2622b8bf4e555b80.tar.xz
redo-b2a3f4f62375f2571725075c2622b8bf4e555b80.zip
Make redo actually create the directories it needs
Diffstat (limited to 'src/redo.c')
-rw-r--r--src/redo.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/redo.c b/src/redo.c
index 40946dc..6cf68c3 100644
--- a/src/redo.c
+++ b/src/redo.c
@@ -11,6 +11,7 @@
#include "build.h"
#include "util.h"
#include "dbg.h"
+#include "filepath.h"
/* Returns the amount of digits a number n has in decimal. */
@@ -19,26 +20,22 @@ static inline int digits(unsigned n) {
}
int main(int argc, char *argv[]) {
- /* create .redo directory */
- if (mkdir(".redo/deps", 0744))
- if (errno != EEXIST) /* TODO: unsafe, dir could be a file or broken symlink */
- fatal(ERRM_MKDIR, ".redo/deps");
+ /* create the dependency store if it doesn't already exist */
+ mkdirp(".redo");
+ mkdirp(".redo/deps");
/* set REDO_ROOT */
char *cwd = getcwd(NULL, 0);
if (!cwd)
fatal("redo: failed to obtain cwd");
-
if (setenv("REDO_ROOT", cwd, 0))
fatal("redo: failed to setenv %s to %s", "REDO_ROOT", cwd);
-
free(cwd);
- srand(time(NULL)); /* TODO: error checking */
- unsigned magic = rand();
-
+ /* set REDO_MAGIC */
+ srand(time(NULL));
char magic_str[digits(UINT_MAX) + 1];
- sprintf(magic_str, "%u", magic);
+ sprintf(magic_str, "%u", rand());
debug("magic number: %s\n", magic_str);