This commit is contained in:
Matteo Paonessa 2018-08-28 21:51:59 +02:00
commit 025bf0ec5b
2 changed files with 48 additions and 31 deletions

View File

@ -49,7 +49,6 @@ cclt_options parse_arguments(char **argv, cs_image_pars *options) {
{0}
};
optparse_init(&opts, argv);
int option;
while ((option = optparse_long(&opts, longopts, NULL)) != -1) {
switch (option) {
@ -65,9 +64,13 @@ 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 = (int) strlen(parameters.output_folder);
int pathlen = strlen(parameters.output_folder);
if (parameters.output_folder[pathlen - 1] != '/' &&
parameters.output_folder[pathlen - 1] != '\\') {
// append the extra slash/backslash
@ -130,8 +133,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;

View File

@ -21,6 +21,9 @@
#include <caesium.h>
#include <limits.h>
#include <math.h>
#ifdef _WIN32
#include <stdint.h>
#endif
#include "utils.h"
#include "vendor/tinydir.h"
@ -110,9 +113,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;