From 7f438d9e1904de4f96f85f47f33743b13b56484d Mon Sep 17 00:00:00 2001 From: Matteo Paonessa Date: Tue, 23 Feb 2016 11:34:58 +0100 Subject: [PATCH] Fixed #2 --- README.md | 5 +---- src/main.c | 12 ++++-------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index af13f35..029e4c7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ ## Caesium Command Line Tools -##### CCLT - v0.9.1-beta (build 20160121) - Copyright © Matteo Paonessa, 2016. All Rights Reserved. +##### CCLT - v0.9.1-beta (build 20160223) - Copyright © Matteo Paonessa, 2016. All Rights Reserved. ---------- @@ -48,13 +48,10 @@ $ caesiumclt -l -R -o ~/output/ ~/Pictures ###### TODO * Code cleaning -* Folder structure support ---------- ###### KNOWN ISSUES -* Strange behaviour with network files: the output base_name is the name of the output subfolder (e.g. -o /path/to/images/compressed /path/to/images -> results in all the output images named as "compressed") -* Resizing works only for powers of two (e.g. 50%, 25%, 16%...) and for JPEGs only * It does not work on Windows unless you port getopt to it ---------- diff --git a/src/main.c b/src/main.c index 645aea7..203412c 100755 --- a/src/main.c +++ b/src/main.c @@ -26,8 +26,6 @@ -//TODO Use a general fuction to support folder separators -//TODO If inputs a folder AND files, send an error //TODO If the output is INSIDE the folder we are passing as input, ignore it or we're gonna go in a infinite loop void cclt_start(cclt_compress_parameters* pars, off_t* i_t_size, off_t* o_t_size) { @@ -52,10 +50,6 @@ void cclt_start(cclt_compress_parameters* pars, off_t* i_t_size, off_t* o_t_size char* output_filename = (char*) malloc ((strlen(output_folder) + 1) * sizeof(char)); - char* i_tmp = (char*) malloc (strlen(input_files[i]) * sizeof(char)); - - - strcpy(i_tmp, input_files[i]); strcpy(output_filename, output_folder); //Append / if was not entered by user @@ -63,8 +57,10 @@ void cclt_start(cclt_compress_parameters* pars, off_t* i_t_size, off_t* o_t_size strcat(output_filename, "/"); } - output_filename = realloc(output_filename, (strlen(output_filename) + strlen(basename(i_tmp))) * sizeof(char)); - output_filename = strcat(output_filename, basename(i_tmp)); + output_filename = realloc(output_filename, (strlen(output_filename) + strlen(basename(input_files[i]))) * sizeof(char)); + output_filename = strcat(output_filename, basename(input_files[i])); + + printf("%s\n", input_files[i]); //Get input stats status = stat(input_files[i], &st_buf);