From 1b9f08a8cdd078995921563879dfd17c6864664f Mon Sep 17 00:00:00 2001 From: Bjoern Forsberg Date: Thu, 17 Aug 2017 13:49:09 +0200 Subject: [PATCH] Default format .spi for file-write is consistent running e.g. mask_create with "--o test" produced a spider-format image named "test", rather than "test.spi". This is now fixed. --- src/filename.cpp | 2 +- src/image.h | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/filename.cpp b/src/filename.cpp index 472c0cca9..933d96f42 100644 --- a/src/filename.cpp +++ b/src/filename.cpp @@ -301,7 +301,7 @@ FileName FileName::getFileFormat() const else if ( (first = rfind("."))!=std::string::npos) result = substr(first + 1); else - result="spi"; + result=""; return result.toLowercase(); } diff --git a/src/image.h b/src/image.h index 760e32716..937715ee3 100644 --- a/src/image.h +++ b/src/image.h @@ -132,6 +132,10 @@ class fImageHandler closeFile(); FileName fileName, headName = ""; + // get the format, checking for possible format specifier before suffix + // getFileFormat("file.spi") will return "spi" + // getFileFormat("file.spi:mrc") will return "mrc" + // getFileFormat("file") will return "" ext_name = name.getFileFormat(); long int dump; @@ -140,6 +144,8 @@ class fImageHandler if (dump > 0) dump--; + // create the filename from a possible input format specifier (file.spi:mrc means "it's called .spi, but it's really a .mrc") + // file.spi:mrc -> file.spi fileName = fileName.removeFileFormat(); size_t found = fileName.find_first_of("%"); @@ -177,6 +183,11 @@ class fImageHandler headName = fileName.addExtension("hed"); fileName = fileName.addExtension("img"); } + else if(ext_name=="") + { + ext_name="spi"; // SPIDER is default format if none is specified + fileName = fileName.addExtension(ext_name); + } // Open image file if ( ( fimg = fopen(fileName.c_str(), wmChar.c_str()) ) == NULL )