From bb1771d95bebd4d23e7841bebb8663528d412771 Mon Sep 17 00:00:00 2001 From: Erik Wernersson Date: Sat, 22 Jun 2024 16:17:38 +0200 Subject: [PATCH 1/4] indentation --- src/dw_util.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/dw_util.c b/src/dw_util.c index a01a22a..7b49a43 100644 --- a/src/dw_util.c +++ b/src/dw_util.c @@ -85,7 +85,7 @@ void dw_gettime(struct timespec * t) char * dw_dirname(const char * path) { - #ifdef WINDOWS +#ifdef WINDOWS size_t maxlen = strlen(path)+1; char * drive = malloc(maxlen); char * dir = malloc(maxlen); @@ -96,13 +96,13 @@ char * dw_dirname(const char * path) free(drive); free(dir); return outpath; - #else +#else char * t = strdup(path); char * _dir = dirname(t); // should not be freed char * dir = strdup(_dir); free(t); return dir; - #endif +#endif } char * dw_basename(const char * path) @@ -128,11 +128,11 @@ char * dw_basename(const char * path) char * dw_getcwd(char * buf, size_t size) { - #ifdef WINDOWS +#ifdef WINDOWS return _getcwd(buf, size); - #else +#else return getcwd(buf, size); - #endif +#endif } int ptr_alignment_B(const void * p) From 9a3ea0a98219241d620dd8f675c5bf2c739d0f6f Mon Sep 17 00:00:00 2001 From: Erik Wernersson Date: Sat, 22 Jun 2024 16:39:35 +0200 Subject: [PATCH 2/4] Issue fix for #70 Prevent addition of '\' for files in the current folder on windows --- src/dw.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/dw.c b/src/dw.c index de4ecd6..0b3a7a6 100644 --- a/src/dw.c +++ b/src/dw.c @@ -941,12 +941,22 @@ void dw_argparsing(int argc, char ** argv, dw_opts * s) char * bname = dw_basename(s->imFile); s->outFile = malloc(strlen(dname) + strlen(bname) + strlen(s->prefix) + 10); assert(s->outFile != NULL); - sprintf(s->outFile, "%s%c%s_%s", dname, FILESEP, s->prefix, bname); + if (strlen(dname) > 0) + { + sprintf(s->outFile, "%s%c%s_%s", dname, FILESEP, s->prefix, bname); + } + else { + sprintf(s->outFile, "%s_%s", s->prefix, bname); + } s->outFolder = malloc(strlen(dname) + 16); assert(s->outFolder != NULL); sprintf(s->outFolder, "%s%c", dname, FILESEP); free(bname); free(dname); + if (s->verbosity > 1) + { + printf("outFile: %s\n", s->outFile); + } } else { char * dname = dw_dirname(s->outFile); free(s->outFolder); @@ -1980,6 +1990,14 @@ float * psf_makeOdd(float * psf, int64_t * pM, int64_t * pN, int64_t *pP) void dcw_init_log(dw_opts * s) { s->log = fopen(s->logFile, "w"); + if (s->log == NULL) + { + fprintf(stderr, "Unable to open %s for writing\n", s->logFile); + fprintf(stderr, + "Please check that you have permissions to write to the folder\n" + "and that the drive is not full\n"); + exit(EXIT_FAILURE); + } assert(s->log != NULL); show_time(s->log); dw_opts_fprint(s->log, s); @@ -2072,6 +2090,8 @@ fftwf_complex * initial_guess(const int64_t M, const int64_t N, const int64_t P, } } } + //printf("writing to one.tif"); + //fim_tiff_write_float("one.tif", one, NULL, wM, wN, wP); // writetif("one.tif", one, wM, wN, wP); fftwf_complex * Fone = fft(one, wM, wN, wP); From 2032e843c78c4a1edd330be5689ab7916946f7e2 Mon Sep 17 00:00:00 2001 From: Erik Wernersson Date: Sat, 22 Jun 2024 18:39:04 +0200 Subject: [PATCH 3/4] _splitpath and _makepath --- src/dw.c | 27 +++++++++------------------ src/dw_util.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 18 deletions(-) diff --git a/src/dw.c b/src/dw.c index 0b3a7a6..ab93d4c 100644 --- a/src/dw.c +++ b/src/dw.c @@ -934,29 +934,20 @@ void dw_argparsing(int argc, char ** argv, dw_opts * s) } + /* Set s->outFile and s->outFolder based on s->imFile */ if(s->outFile == NULL) - { - /* Set s->outFile and s->outFolder based on s->imFile */ - char * dname = dw_dirname(s->imFile); - char * bname = dw_basename(s->imFile); - s->outFile = malloc(strlen(dname) + strlen(bname) + strlen(s->prefix) + 10); - assert(s->outFile != NULL); - if (strlen(dname) > 0) - { - sprintf(s->outFile, "%s%c%s_%s", dname, FILESEP, s->prefix, bname); - } - else { - sprintf(s->outFile, "%s_%s", s->prefix, bname); - } + { + s->outFile = dw_prefix_file(s->imFile, s->prefix); + + char * dname = dw_dirname(s->imFile); s->outFolder = malloc(strlen(dname) + 16); assert(s->outFolder != NULL); - sprintf(s->outFolder, "%s%c", dname, FILESEP); - free(bname); + sprintf(s->outFolder, "%s%c", dname, FILESEP); free(dname); - if (s->verbosity > 1) + if(s->verbosity > 1) { - printf("outFile: %s\n", s->outFile); - } + printf("outFile: %s, outFolder: %s\n", s->outFile, s->outFolder); + } } else { char * dname = dw_dirname(s->outFile); free(s->outFolder); diff --git a/src/dw_util.c b/src/dw_util.c index 7b49a43..cf2899d 100644 --- a/src/dw_util.c +++ b/src/dw_util.c @@ -93,12 +93,14 @@ char * dw_dirname(const char * path) _splitpath(path, drive, dir, NULL, NULL); char * outpath = malloc(maxlen); _makepath(outpath, drive, dir, NULL, NULL); + // Adds a trailing '\' free(drive); free(dir); return outpath; #else char * t = strdup(path); char * _dir = dirname(t); // should not be freed + // Does not add a trailing '/' char * dir = strdup(_dir); free(t); return dir; @@ -354,7 +356,40 @@ int getline(char **lineptr, size_t *n, FILE *stream) char * dw_prefix_file(const char * inFile, const char * prefix) { +#ifdef WINDOWS + + char* drive = calloc(strlen(inFile) + 16, 1); + char* dir = calloc(strlen(inFile) + 16, 1); + char* fname = calloc(strlen(inFile) + 16, 1); + char* ext = calloc(strlen(inFile) + 16, 1); + + _splitpath( + inFile, + drive, + dir, + fname, + ext + ); + + char* pre_fname = calloc(strlen(fname) + strlen(prefix) + 16, 1); + sprintf(pre_fname, "%s_%s", prefix, fname); + char* outFile = calloc(strlen(inFile) + strlen(prefix) + 128, 1); + + _makepath( + outFile, + drive, + dir, + pre_fname, + ext + ); + free(drive); + free(dir); + free(fname); + free(pre_fname); + free(ext); + return outFile; +#else char * dname = dw_dirname(inFile); assert(dname != NULL); char * fname = dw_basename(inFile); @@ -373,6 +408,7 @@ dw_prefix_file(const char * inFile, const char * prefix) free(fname); return outFile; +#endif } float abbe_res_xy(float lambda, float NA) From 984c5a4e6e6dc171b182ada5cafe6fbd70253284 Mon Sep 17 00:00:00 2001 From: Erik Wernersson Date: Sat, 22 Jun 2024 18:42:22 +0200 Subject: [PATCH 4/4] Updated to version 0.4.3 --- CHANGELOG.md | 11 +++++++++++ README.md | 2 +- src/dw_version.h | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07174b6..26ce8af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # CHANGELOG +## 0.4.3 +- Fixed [issue #70](https://github.com/elgw/deconwolf/issues/70) which + affected windows builds only. + +- Dw will now give a error message if the log file can't be opened + instead of quietly crashing. + +- Disabled some debug code that caused dw to write the file + (`one.tif`) every time that is was run. It has been doing so since + version 0.4.1. + ## 0.4.2 - VkFFT upgraded from v1.3.3 to v1.3.4. - Fixed an issue preventing anything than `--bq 0` to be used on diff --git a/README.md b/README.md index c4a3884..36e6db3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# deconwolf v0.4.2 +# deconwolf v0.4.3 **deconwolf**[^9] is a software for 3-D deconvolution of fluorescent wide-field images: diff --git a/src/dw_version.h b/src/dw_version.h index 4f6c5e8..ca70c57 100644 --- a/src/dw_version.h +++ b/src/dw_version.h @@ -2,7 +2,7 @@ #define DW_VERSION_MAJOR "0" #define DW_VERSION_MINOR "4" -#define DW_VERSION_PATCH "2" +#define DW_VERSION_PATCH "3" #define deconwolf_version DW_VERSION_MAJOR "." \ DW_VERSION_MINOR "." \ DW_VERSION_PATCH