This commit is contained in:
Matteo Paonessa 2017-12-29 23:18:20 +01:00
parent 67d1d3e853
commit e1a6c862a2
3 changed files with 52 additions and 6 deletions

View File

@ -0,0 +1,29 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<Objective-C-extensions>
<file>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
</file>
<class>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
</class>
<extensions>
<pair source="cpp" header="h" fileNamingConvention="NONE" />
<pair source="c" header="h" fileNamingConvention="NONE" />
</extensions>
</Objective-C-extensions>
</code_scheme>
</component>

View File

@ -13,7 +13,7 @@
---------- ----------
###### TESTED PLATFORMS ###### TESTED PLATFORMS
* Mac OS X Sierra (v10.13.0) * Mac OS X High Sierra (v10.13.1)
* Ubuntu 16.04 * Ubuntu 16.04
* Windows 10 * Windows 10
@ -60,6 +60,7 @@ $ caesiumclt -q 0 -RS -o ~/output/ ~/Pictures
---------- ----------
###### CHANGELOG ###### CHANGELOG
* 0.11.0-beta - Fixing paths issues and dry-run option
* 0.10.2-beta - Bugfixes & full Windows support * 0.10.2-beta - Bugfixes & full Windows support
* 0.10.1-beta - All features are available * 0.10.1-beta - All features are available
* 0.10.0-beta - Switched to cmake build system and libcaesium * 0.10.0-beta - Switched to cmake build system and libcaesium

View File

@ -1,9 +1,11 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#ifdef _WIN32 #ifdef _WIN32
#include <direct.h> #include <direct.h>
#endif #endif
#include "helper.h" #include "helper.h"
#include "optparse.h" #include "optparse.h"
#include "utils.h" #include "utils.h"
@ -34,7 +36,7 @@ cclt_options parse_arguments(char **argv, cs_image_pars *options)
while ((option = optparse_long(&opts, longopts, NULL)) != -1) { while ((option = optparse_long(&opts, longopts, NULL)) != -1) {
switch (option) { switch (option) {
case 'q': case 'q':
options->jpeg.quality = (int)strtol(opts.optarg, (char **)NULL, 10);; options->jpeg.quality = (int) strtol(opts.optarg, (char **) NULL, 10);;
if (options->jpeg.quality < 0 || options->jpeg.quality > 100) { if (options->jpeg.quality < 0 || options->jpeg.quality > 100) {
display_error(ERROR, 1); display_error(ERROR, 1);
} }
@ -47,11 +49,13 @@ cclt_options parse_arguments(char **argv, cs_image_pars *options)
} else { } else {
realpath(opts.optarg, parameters.output_folder); realpath(opts.optarg, parameters.output_folder);
} }
if (parameters.output_folder[strlen(opts.optarg) - 1] != '/' && parameters.output_folder[strlen(opts.optarg) - 1] != '\\') { if (parameters.output_folder[strlen(opts.optarg) - 1] != '/' &&
parameters.output_folder[strlen(opts.optarg) - 1] != '\\') {
#ifdef _WIN32 #ifdef _WIN32
snprintf(parameters.output_folder, strlen(parameters.output_folder) + 2, "%s\\", parameters.output_folder); snprintf(parameters.output_folder, strlen(parameters.output_folder) + 2, "%s\\", parameters.output_folder);
#else #else
snprintf(parameters.output_folder, strlen(parameters.output_folder) + 2, "%s/", parameters.output_folder); snprintf(parameters.output_folder, strlen(parameters.output_folder) + 2, "%s/",
parameters.output_folder);
#endif #endif
} }
break; break;
@ -103,6 +107,16 @@ cclt_options parse_arguments(char **argv, cs_image_pars *options)
if (is_directory(resolved_path)) { if (is_directory(resolved_path)) {
if (!files_flag) { if (!files_flag) {
folders_flag = true; folders_flag = true;
if (resolved_path[strlen(resolved_path) - 1] != '/' && resolved_path[strlen(resolved_path) - 1] != '\\') {
#ifdef _WIN32
resolved_path[strlen(resolved_path)] = '\\';
#else
resolved_path[strlen(resolved_path)] = '/';
#endif
resolved_path[strlen(resolved_path)] = '\0';
}
snprintf(parameters.input_folder, strlen(resolved_path) + 1, "%s", resolved_path); snprintf(parameters.input_folder, strlen(resolved_path) + 1, "%s", resolved_path);
int count = 0; int count = 0;
count = scan_folder(resolved_path, &parameters, parameters.recursive); count = scan_folder(resolved_path, &parameters, parameters.recursive);
@ -122,10 +136,12 @@ cclt_options parse_arguments(char **argv, cs_image_pars *options)
} }
//Check if the output folder is a subfolder of the input to avoid infinite loops //Check if the output folder is a subfolder of the input to avoid infinite loops
//but just if the -R option is set
//However, if the folders are the same, we can let it go as it will overwrite the files //However, if the folders are the same, we can let it go as it will overwrite the files
if (folders_flag) { if (folders_flag) {
if (strstr(parameters.output_folder, parameters.input_folder) != NULL if (strstr(parameters.output_folder, parameters.input_folder) != NULL
&& strcmp(parameters.output_folder, parameters.input_folder) != 0) { && strcmp(parameters.output_folder, parameters.input_folder) != 0
&& parameters.recursive) {
display_error(ERROR, 12); display_error(ERROR, 12);
} }
} }
@ -171,7 +187,7 @@ int start_compression(cclt_options *options, cs_image_pars *parameters)
options->output_folder, filename); options->output_folder, filename);
} else { } else {
/* /*
* Otherwise, we nee to compute the whole directory structure * Otherwise, we need to compute the whole directory structure
* We are sure we have a folder only as input, so that's the root * We are sure we have a folder only as input, so that's the root
* Just compute the subfolders without the filename, make them and append the filename * Just compute the subfolders without the filename, make them and append the filename
* A piece of cake <3 * A piece of cake <3