Skip to content

BUG: Remove '%' from tmp file names - #2432

Merged
blowekamp merged 1 commit into
SimpleITK:mainfrom
dave3d:ShowTmpFileBug
Sep 24, 2025
Merged

blowekamp merged 1 commit into
SimpleITK:mainfrom
dave3d:ShowTmpFileBug

Conversation

@dave3d

@dave3d dave3d commented Sep 23, 2025

Copy link
Copy Markdown
Member

When passing an image file to ImageJ, it does not like '%' in the file name. If the ImageViewer has a title, the file name is derived from it.

When passing an image file to ImageJ, it does not like '%' in the
file name.  If the ImageViewer has a title, the file name is derived
from it.
@dave3d
dave3d requested review from blowekamp and zivy September 23, 2025 17:58
@@ -954,16 +955,14 @@ FormatFileName(const std::string & TempDirectory,
if (!name.empty())
{
std::string n = name;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It took me a moment to figure out the erase remove idiom below:
https://en.wikipedia.org/wiki/Erase–remove_idiom

But if I understand it, since you are constructing the string here you can do something like

std::string n(name.begin(), std::remove_if(n.begin(), n.end(), &IsBadCharacter), n.end());

But tangental to the PR.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, looking at this old code it's not the way I'd do it now, but oh well.

Also, I tried out every other non-alphanumeric character and ImageJ didn't have problems with them.

@blowekamp
blowekamp merged commit 01e1af1 into SimpleITK:main Sep 24, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants