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.c b/src/dw.c index de4ecd6..ab93d4c 100644 --- a/src/dw.c +++ b/src/dw.c @@ -934,19 +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); - sprintf(s->outFile, "%s%c%s_%s", dname, FILESEP, 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) + { + printf("outFile: %s, outFolder: %s\n", s->outFile, s->outFolder); + } } else { char * dname = dw_dirname(s->outFile); free(s->outFolder); @@ -1980,6 +1981,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 +2081,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); diff --git a/src/dw_util.c b/src/dw_util.c index a01a22a..cf2899d 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); @@ -93,16 +93,18 @@ 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 +#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; - #endif +#endif } char * dw_basename(const char * path) @@ -128,11 +130,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) @@ -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) 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