From 1bd3533073ef6b2c72ebe15b9220bb46e9459985 Mon Sep 17 00:00:00 2001 From: Matteo Paonessa Date: Sun, 26 Aug 2018 14:19:07 +0200 Subject: [PATCH] Windows fixes --- src/helper.c | 9 +++++++++ src/utils.c | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/src/helper.c b/src/helper.c index 8775256..7cdf78f 100644 --- a/src/helper.c +++ b/src/helper.c @@ -65,7 +65,11 @@ cclt_options parse_arguments(char **argv, cs_image_pars *options) if (opts.optarg[0] == '~') { snprintf(parameters.output_folder, strlen(opts.optarg) + 1, "%s", opts.optarg); } else { +#ifdef _WIN32 + _fullpath(parameters.output_folder, opts.optarg, MAX_PATH); +#else realpath(opts.optarg, parameters.output_folder); +#endif } int pathlen = strlen(parameters.output_folder); if (parameters.output_folder[pathlen - 1] != '/' && @@ -127,8 +131,13 @@ cclt_options parse_arguments(char **argv, cs_image_pars *options) #endif } } else { +#ifdef _WIN32 + _fullpath(resolved_path, arg, MAX_PATH); +#else realpath(arg, resolved_path); +#endif } + if (is_directory(resolved_path)) { if (!files_flag) { folders_flag = true; diff --git a/src/utils.c b/src/utils.c index 3060a70..c641b8b 100644 --- a/src/utils.c +++ b/src/utils.c @@ -21,6 +21,9 @@ #include #include #include +#ifdef _WIN32 +#include +#endif #include "utils.h" #include "vendor/tinydir.h" @@ -109,9 +112,15 @@ int mkpath(const char *pathname) return -1; } /* make this one if parent has been made */ +#ifdef _WIN32 + if (mkdir(pathname) == 0) { + return 0; + } +#else if (mkdir(pathname, 0777) == 0) { return 0; } +#endif /* if it already exists that is fine */ if (errno == EEXIST) { return 0;