diff options
author | Tharre <tharre3@gmail.com> | 2014-07-29 15:23:21 +0200 |
---|---|---|
committer | Tharre <tharre3@gmail.com> | 2014-07-29 15:23:21 +0200 |
commit | 2a5673b6bf86f4ba89aabf6ec5c82a2d5479d4ae (patch) | |
tree | 1c13fb96b20396c5e9b73ad409a17b72e346d93a /src/redo.c | |
parent | 058398673a656dd3d58fccb90a94a16fcfc27e71 (diff) | |
download | redo-2a5673b6bf86f4ba89aabf6ec5c82a2d5479d4ae.tar.gz redo-2a5673b6bf86f4ba89aabf6ec5c82a2d5479d4ae.tar.xz redo-2a5673b6bf86f4ba89aabf6ec5c82a2d5479d4ae.zip |
Create .redo and set REDO_ROOT to cwd
Diffstat (limited to 'src/redo.c')
-rw-r--r-- | src/redo.c | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -1,9 +1,31 @@ #include <stdio.h> +#include <stdlib.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <unistd.h> #include "build.h" #include "util.h" +#include "dbg.h" + +/* TODO: for some reason this header is not included */ +int setenv(const char *name, const char *value, int overwrite); int main(int argc, char *argv[]) { + /* create .redo directory */ + if (mkdir(".redo", 0744)) + fatal(ERRM_MKDIR, ".redo"); + + /* 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); + if (argc < 2) { build_target("all"); } else { |