Skip to content

Commit

Permalink
Handle windows slashes in path in MetaImageExporter
Browse files Browse the repository at this point in the history
  • Loading branch information
smistad committed Dec 8, 2023
1 parent 4c47a27 commit 8671792
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions source/FAST/Exporters/FileExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
namespace fast {

void FileExporter::setFilename(std::string filename) {
#ifdef WIN32
m_filename = replace(filename, "\\", "/");
#else
m_filename = filename;
#endif
setModified(true);
}

Expand Down
14 changes: 14 additions & 0 deletions source/FAST/Exporters/Tests/MetaImageExporterTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ TEST_CASE("No input given to the MetaImageExporter", "[fast][MetaImageExporter]"
CHECK_THROWS(exporter->update());
}


#ifdef WIN32
TEST_CASE("Windows path slashes used in MetaImageExporter", "[fast][MetaImageExporter]") {
auto image = Image::create(32, 32, TYPE_UINT8, 1); // Create dummy image
createDirectories("mhd_test");
auto exporter = MetaImageExporter::create("mhd_test\\image.mhd")
->connect(image);
CHECK_NOTHROW(exporter->run());

auto importer = MetaImageImporter::create("mhd_test/image.mhd");
CHECK_NOTHROW(importer->run());
}
#endif

TEST_CASE("Write a 2D image with the MetaImageExporter", "[fast][MetaImageExporter]") {
// Create some metadata
Vector3f spacing;
Expand Down

0 comments on commit 8671792

Please sign in to comment.