Fixing #39
This commit is contained in:
parent
586ddb6efd
commit
4a229a3bbd
|
@ -1,5 +1,5 @@
|
|||
## Caesium CommandLineTools
|
||||
##### caesium-clt - v0.13.0-beta (build 20190928) - Copyright © Matteo Paonessa, 2018. All Rights Reserved.
|
||||
##### caesium-clt - v0.13.1-beta (build 20191013) - Copyright © Matteo Paonessa, 2019. All Rights Reserved.
|
||||
[](https://travis-ci.org/Lymphatus/caesium-clt)
|
||||
----------
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
|||
###### TESTED PLATFORMS
|
||||
* Mac OS X Mojave (v10.14.4)
|
||||
* Ubuntu 19.04
|
||||
* Windows 10
|
||||
|
||||
----------
|
||||
|
||||
|
@ -42,6 +41,8 @@ See INSTALL.md for more details.
|
|||
Note that this may end up building a large set of files to be compressed and should be used carefully.
|
||||
- `-S, --keep-structure`
|
||||
If the input is a folder, and the `-R` option is set, caesiumclt will compress all the files keeping the original folder structure.
|
||||
- `-O, --overwrite`
|
||||
Sets the overwrite policy: `all` will overwrite any existing file, `prompt` will ask each time before overwriting, `bigger` will overwrite bigger files only, and `none` will silently skip existing files.
|
||||
- `-d, --dry-run`
|
||||
If this option is set, no files will be compressed, but the entire process will just be simulated.
|
||||
Useful for checking if all the files will be correctly handled.
|
||||
|
@ -95,6 +96,7 @@ $ caesiumclt -q 0 -RS -o ~/output/ ~/Pictures
|
|||
|
||||
###### CHANGELOG
|
||||
* 0.13.0-beta - Bugfix
|
||||
* 0.13.0-beta - Bugfix
|
||||
* 0.12.1-beta - Bugfix
|
||||
* 0.12.0-beta - Resizing (experimental)
|
||||
* 0.11.0-beta - Fixing paths issues and dry-run option
|
||||
|
|
2
config.h
2
config.h
|
@ -1,4 +1,4 @@
|
|||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 13
|
||||
#define VERSION_PATCH 0
|
||||
#define VERSION_PATCH 1
|
||||
|
||||
|
|
10
src/error.c
10
src/error.c
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*
|
||||
* Copyright 2018 Matteo Paonessa
|
||||
* Copyright 2019 Matteo Paonessa
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
@ -58,13 +58,17 @@ const char *get_error_message(int code) {
|
|||
case 11:
|
||||
return "-S has no effect without -R.";
|
||||
case 12:
|
||||
return "Cannot set output folder inside the input one";
|
||||
return "Cannot set output folder inside the input one.";
|
||||
case 13:
|
||||
return "Scale factor must be between (0, 1.0]. Setting it to 1.0.";
|
||||
case 14:
|
||||
return "Scale factor parsing error.";
|
||||
case 15:
|
||||
return "Overwrite policy value is invalid. Using 'all'.";
|
||||
return "Overwrite policy value is invalid. Using 'bigger'.";
|
||||
case 16:
|
||||
return "Cannot get the full output path.";
|
||||
case 17:
|
||||
return "Cannot create the output folder.";
|
||||
|
||||
default:
|
||||
return "Unrecognized error.";
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*
|
||||
* Copyright 2018 Matteo Paonessa
|
||||
* Copyright 2019 Matteo Paonessa
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
|
24
src/helper.c
24
src/helper.c
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*
|
||||
* Copyright 2018 Matteo Paonessa
|
||||
* Copyright 2019 Matteo Paonessa
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
@ -18,6 +18,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <direct.h>
|
||||
|
@ -68,7 +69,23 @@ cclt_options parse_arguments(char **argv, cs_image_pars *options) {
|
|||
#ifdef _WIN32
|
||||
_fullpath(parameters.output_folder, opts.optarg, MAX_PATH);
|
||||
#else
|
||||
realpath(opts.optarg, parameters.output_folder);
|
||||
char* computedPath = realpath(opts.optarg, parameters.output_folder);
|
||||
if (computedPath == NULL) {
|
||||
//Folder does not exists and may just fail on some systems, like Docker Alpine
|
||||
if (errno == 2) {
|
||||
if (mkpath(opts.optarg) == 0) {
|
||||
computedPath = realpath(opts.optarg, parameters.output_folder);
|
||||
if (computedPath == NULL) {
|
||||
//Just throw an error here
|
||||
display_error(ERROR, 16);
|
||||
}
|
||||
} else {
|
||||
display_error(ERROR, 17);
|
||||
}
|
||||
} else {
|
||||
display_error(ERROR, 16);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
int pathlen = (int)strlen(parameters.output_folder);
|
||||
|
@ -155,7 +172,6 @@ cclt_options parse_arguments(char **argv, cs_image_pars *options) {
|
|||
}
|
||||
|
||||
snprintf(parameters.input_folder, strlen(resolved_path) + 1, "%s", resolved_path);
|
||||
int count = 0;
|
||||
scan_folder(resolved_path, ¶meters, parameters.recursive);
|
||||
if (parameters.files_count == 0) {
|
||||
display_error(WARNING, 3);
|
||||
|
@ -242,7 +258,7 @@ int start_compression(cclt_options *options, cs_image_pars *parameters) {
|
|||
mkpath(output_full_folder);
|
||||
}
|
||||
|
||||
//Calculating the total input file size, ignoring of we are going to skip them later
|
||||
//Calculating the total input file size, ignoring if we are going to skip them later
|
||||
file_size = get_file_size(options->input_files[i]);
|
||||
if (file_size == 0) {
|
||||
//We could not open the file
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*
|
||||
* Copyright 2018 Matteo Paonessa
|
||||
* Copyright 2019 Matteo Paonessa
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*
|
||||
* Copyright 2018 Matteo Paonessa
|
||||
* Copyright 2019 Matteo Paonessa
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
|
11
src/utils.c
11
src/utils.c
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*
|
||||
* Copyright 2018 Matteo Paonessa
|
||||
* Copyright 2019 Matteo Paonessa
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
@ -21,6 +21,7 @@
|
|||
#include <caesium.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
#ifdef _WIN32
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
@ -40,10 +41,10 @@ void print_help()
|
|||
"\t-q, --quality\t\tset output file quality between [0-100], 0 for optimization\n"
|
||||
"\t-e, --exif\t\tkeeps EXIF info during compression\n"
|
||||
"\t-o, --output\t\toutput folder\n"
|
||||
"\t-s, --scale\t\tscale the image. Allowed formats are [.x, 0.x, n/d, xx%%].\n\t\t\t\tMust be > 0 and <= 1.0.\n"
|
||||
"\t-s, --scale\t\t[EXPERIMENTAL] scale the image. Allowed formats are [.x, 0.x, n/d, xx%%].\n\t\t\t\tMust be > 0 and <= 1.0.\n"
|
||||
"\t-R, --recursive\t\tif input is a folder, scan subfolders too\n"
|
||||
"\t-S, --keep-structure\tkeep the folder structure, use with -R\n"
|
||||
"\t-O, --overwrite\t\tOverwrite policy: all, none, prompt, bigger. Default is all.\n"
|
||||
"\t-O, --overwrite\t\tOverwrite policy: all, none, prompt, bigger. Default is bigger.\n"
|
||||
"\t-d, --dry-run\t\tdo not really compress files but just show output paths\n"
|
||||
"\t-h, --help\t\tdisplay this help and exit\n"
|
||||
"\t-v, --version\t\toutput version information and exit\n\n");
|
||||
|
@ -116,7 +117,7 @@ int mkpath(const char *pathname)
|
|||
return 0;
|
||||
}
|
||||
#else
|
||||
if (mkdir(pathname, 0777) == 0) {
|
||||
if (mkdir(pathname, 0755) == 0) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -276,7 +277,7 @@ overwrite_policy parse_overwrite_policy(const char* overwrite_string)
|
|||
return all;
|
||||
}
|
||||
display_error(WARNING, 15);
|
||||
return all;
|
||||
return bigger;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*
|
||||
* Copyright 2018 Matteo Paonessa
|
||||
* Copyright 2019 Matteo Paonessa
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
|
Loading…
Reference in New Issue