Skip to content

Commit

Permalink
Default format .spi for file-write is consistent
Browse files Browse the repository at this point in the history
running e.g. mask_create with "--o test" produced a spider-format image
named "test", rather than "test.spi". This is now fixed.
  • Loading branch information
bforsbe committed Aug 17, 2017
1 parent 4c37af0 commit 1b9f08a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/filename.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

}
Expand Down
11 changes: 11 additions & 0 deletions src/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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("%");
Expand Down Expand Up @@ -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 )
Expand Down

0 comments on commit 1b9f08a

Please sign in to comment.