diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/copy.c | 2 | ||||
-rw-r--r-- | src/main.c | 8 | ||||
-rw-r--r-- | src/msg.c | 10 |
3 files changed, 12 insertions, 8 deletions
@@ -42,7 +42,7 @@ copy_recursively(const char *fpath, const char *path = fpath + strlen(msg->base_directory) + 1; char *output_path = NULL; - asprintf(&output_path, "%s/%s", OUTPUT, path); + asprintf(&output_path, "%s/%s", msg->output_directory, path); if (typeflag == FTW_D) goto exit; @@ -39,11 +39,13 @@ main(int argc, char **argv) { int opt; msg = malloc(sizeof(msg_t)); + msg->base_directory = "."; + msg->output_directory = "dist"; while ((opt = getopt(argc, argv, "o:h")) != -1) { switch (opt) { case 'o': - /* msg.output_directory = optarg; */ + msg->output_directory = optarg; break; case 'h': default: @@ -52,9 +54,7 @@ main(int argc, char **argv) } } - if (optind == argc) - msg->base_directory = "."; - else + if (optind < argc) msg->base_directory = argv[optind]; int r = run(); @@ -49,9 +49,13 @@ handle_file(const char *path) char *dot = strrchr(inpath, '.'); if (dot && strcmp(dot, ".md") == 0) { - asprintf(&outpath, "%s/%.*s.html", OUTPUT, (int) strlen(path) - 3, path); + asprintf(&outpath, + "%s/%.*s.html", + msg->output_directory, + (int) strlen(path) - 3, + path); } else { - asprintf(&outpath, "%s/%s", OUTPUT, path); + asprintf(&outpath, "%s/%s", msg->output_directory, path); } char *temp_outpath = strdup(outpath); @@ -118,7 +122,7 @@ run(void) base_template = template_create(); - int err = mkdir(OUTPUT, 0700); + int err = mkdir(msg->output_directory, 0700); if (err != 0 && errno != EEXIST) { perror("mkdir"); return EXIT_FAILURE; |