From 75c05b4437c275888f448fd3ba6ad402a757efda Mon Sep 17 00:00:00 2001 From: valerio <valerio@5a81b35b-ba03-0410-adc8-b2c5c5119f08> Date: Sun, 21 Mar 2010 17:35:11 +0000 Subject: [PATCH] Support for upper case extensions git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@1854 5a81b35b-ba03-0410-adc8-b2c5c5119f08 --- modules/gui/src/remote_loader.cc | 1 - modules/io/src/img/map_io_dat_handler.cc | 4 ++-- modules/io/src/img/map_io_dat_handler.hh | 2 +- modules/io/src/img/map_io_dm3_handler.cc | 4 ++-- modules/io/src/img/map_io_dm3_handler.hh | 2 +- modules/io/src/img/map_io_dx_handler.cc | 4 ++-- modules/io/src/img/map_io_dx_handler.hh | 2 +- modules/io/src/img/map_io_handler.hh | 4 ++-- modules/io/src/img/map_io_jpk_handler.cc | 4 ++-- modules/io/src/img/map_io_jpk_handler.hh | 2 +- modules/io/src/img/map_io_mrc_handler.cc | 6 +++--- modules/io/src/img/map_io_mrc_handler.hh | 2 +- modules/io/src/img/map_io_nanoscope_handler.cc | 4 ++-- modules/io/src/img/map_io_nanoscope_handler.hh | 2 +- modules/io/src/img/map_io_png_handler.cc | 4 ++-- modules/io/src/img/map_io_png_handler.hh | 2 +- modules/io/src/img/map_io_situs_handler.cc | 4 ++-- modules/io/src/img/map_io_situs_handler.hh | 2 +- modules/io/src/img/map_io_spi_handler.cc | 4 ++-- modules/io/src/img/map_io_spi_handler.hh | 2 +- modules/io/src/img/map_io_tiff_handler.cc | 4 ++-- modules/io/src/img/map_io_tiff_handler.hh | 2 +- modules/io/src/io_manager.cc | 11 +++++++---- 23 files changed, 40 insertions(+), 38 deletions(-) diff --git a/modules/gui/src/remote_loader.cc b/modules/gui/src/remote_loader.cc index c79abbbcf..60ae7c60a 100644 --- a/modules/gui/src/remote_loader.cc +++ b/modules/gui/src/remote_loader.cc @@ -164,4 +164,3 @@ OST_REGISTER_WIDGET_WITH_DEFAULT_FACTORY(ost::gui, RemoteLoader, "Remote Loader" }} - diff --git a/modules/io/src/img/map_io_dat_handler.cc b/modules/io/src/img/map_io_dat_handler.cc index e9642373c..988d590e5 100644 --- a/modules/io/src/img/map_io_dat_handler.cc +++ b/modules/io/src/img/map_io_dat_handler.cc @@ -74,9 +74,9 @@ bool MapIODatHandler::MatchType(const ImageFormatBase& type) return false; } -bool MapIODatHandler::MatchSuffix(const boost::filesystem::path& loc) +bool MapIODatHandler::MatchSuffix(const String& loc) { - if(detail::FilenameEndsWith(loc.string(),".dat") || detail::FilenameEndsWith(loc.string(),".img") ) { + if(detail::FilenameEndsWith(loc,".dat") || detail::FilenameEndsWith(loc,".img") ) { return true; } return false; diff --git a/modules/io/src/img/map_io_dat_handler.hh b/modules/io/src/img/map_io_dat_handler.hh index e6964f819..92335aa17 100644 --- a/modules/io/src/img/map_io_dat_handler.hh +++ b/modules/io/src/img/map_io_dat_handler.hh @@ -60,7 +60,7 @@ class DLLEXPORT_OST_IO MapIODatHandler: public MapIOHandler virtual void Export(const img::MapHandle& sh, std::ostream& loc,const ImageFormatBase& formatstruct) const; static bool MatchContent(unsigned char* header); static bool MatchType(const ImageFormatBase& type); - static bool MatchSuffix(const boost::filesystem::path& loc); + static bool MatchSuffix(const String& loc); static String GetFormatName() { return String("Dat"); } static String GetFormatDescription() {return String("Simple binary format for square images");} }; diff --git a/modules/io/src/img/map_io_dm3_handler.cc b/modules/io/src/img/map_io_dm3_handler.cc index 2ff70625d..c8da38084 100644 --- a/modules/io/src/img/map_io_dm3_handler.cc +++ b/modules/io/src/img/map_io_dm3_handler.cc @@ -636,9 +636,9 @@ bool MapIODm3Handler::MatchType(const ImageFormatBase& type) } return false; } -bool MapIODm3Handler::MatchSuffix(const boost::filesystem::path& loc) +bool MapIODm3Handler::MatchSuffix(const String& loc) { - if(detail::FilenameEndsWith(loc.string(),".dm3") ) { + if(detail::FilenameEndsWith(loc,".dm3") ) { return true; } return false; diff --git a/modules/io/src/img/map_io_dm3_handler.hh b/modules/io/src/img/map_io_dm3_handler.hh index c09832a5a..e958de070 100644 --- a/modules/io/src/img/map_io_dm3_handler.hh +++ b/modules/io/src/img/map_io_dm3_handler.hh @@ -48,7 +48,7 @@ class DLLEXPORT_OST_IO MapIODm3Handler: public MapIOHandler virtual void Export(const img::MapHandle& sh, std::ostream& loc,const ImageFormatBase& formatstruct) const; static bool MatchContent(unsigned char* header); static bool MatchType(const ImageFormatBase& type); - static bool MatchSuffix(const boost::filesystem::path& loc); + static bool MatchSuffix(const String& loc); static String GetFormatName() { return String("Dm3"); } static String GetFormatDescription() {return String("Format used by Gatan Inc.'s Digital Micrograph software");} diff --git a/modules/io/src/img/map_io_dx_handler.cc b/modules/io/src/img/map_io_dx_handler.cc index 7c564eaab..f8f38fad1 100644 --- a/modules/io/src/img/map_io_dx_handler.cc +++ b/modules/io/src/img/map_io_dx_handler.cc @@ -264,9 +264,9 @@ bool MapIODxHandler::MatchType(const ImageFormatBase& formatstruct) } return false; } -bool MapIODxHandler::MatchSuffix(const boost::filesystem::path& loc) +bool MapIODxHandler::MatchSuffix(const String& loc) { - if(detail::FilenameEndsWith(loc.string(),".dx") ) { + if(detail::FilenameEndsWith(loc,".dx") ) { return true; } return false; diff --git a/modules/io/src/img/map_io_dx_handler.hh b/modules/io/src/img/map_io_dx_handler.hh index f54c6ca86..991c9b820 100644 --- a/modules/io/src/img/map_io_dx_handler.hh +++ b/modules/io/src/img/map_io_dx_handler.hh @@ -62,7 +62,7 @@ class DLLEXPORT_OST_IO MapIODxHandler: public MapIOHandler std::ostream& loc, const ImageFormatBase& formatstruct) const; static bool MatchContent(unsigned char* header); static bool MatchType(const ImageFormatBase& type); - static bool MatchSuffix(const boost::filesystem::path& locx); + static bool MatchSuffix(const String& locx); static String GetFormatName() { return String("Dx"); }; static String GetFormatDescription() { return String("Format used by the OpenDX software package"); }; diff --git a/modules/io/src/img/map_io_handler.hh b/modules/io/src/img/map_io_handler.hh index 3be88313a..1912b9c60 100644 --- a/modules/io/src/img/map_io_handler.hh +++ b/modules/io/src/img/map_io_handler.hh @@ -46,7 +46,7 @@ public: virtual ~MapIOHandlerFactoryBase() {} virtual bool MatchContent(unsigned char* header) const = 0; virtual bool MatchType(const ImageFormatBase& type) const = 0; - virtual bool MatchSuffix(const boost::filesystem::path& loc) const =0 ; + virtual bool MatchSuffix(const String& loc) const =0 ; virtual MapIOHandlerPtr Create() const = 0 ; virtual String GetFormatName() const =0; virtual String GetFormatDescription() const =0; @@ -67,7 +67,7 @@ class MapIOHandlerFactory: public MapIOHandlerFactoryBase return HANDLER::MatchType(type); } - virtual bool MatchSuffix(const boost::filesystem::path& loc) const { + virtual bool MatchSuffix(const String& loc) const { return HANDLER::MatchSuffix(loc); } diff --git a/modules/io/src/img/map_io_jpk_handler.cc b/modules/io/src/img/map_io_jpk_handler.cc index f941c37df..2f36a21ed 100644 --- a/modules/io/src/img/map_io_jpk_handler.cc +++ b/modules/io/src/img/map_io_jpk_handler.cc @@ -300,9 +300,9 @@ bool MapIOJpkHandler::MatchType(const ImageFormatBase& formatstruct) return false; } -bool MapIOJpkHandler::MatchSuffix(const boost::filesystem::path& loc) +bool MapIOJpkHandler::MatchSuffix(const String& loc) { - if(detail::FilenameEndsWith(loc.string(),".jpk") ) { + if(detail::FilenameEndsWith(loc,".jpk") ) { return true; } return false; diff --git a/modules/io/src/img/map_io_jpk_handler.hh b/modules/io/src/img/map_io_jpk_handler.hh index 074c632de..be93eb916 100644 --- a/modules/io/src/img/map_io_jpk_handler.hh +++ b/modules/io/src/img/map_io_jpk_handler.hh @@ -48,7 +48,7 @@ class DLLEXPORT_OST_IO MapIOJpkHandler: public MapIOTiffHandler void Export(const img::MapHandle& image, std::ostream& loc,const ImageFormatBase& formatstruct) const; static bool MatchContent(unsigned char* header); static bool MatchType(const ImageFormatBase& type); - static bool MatchSuffix(const boost::filesystem::path& loc); + static bool MatchSuffix(const String& loc); static String GetFormatName() { return String("Jpk");} static String GetFormatDescription() { return String("Format used by JPK Instruments AG's software (Customized Tiff format)"); } diff --git a/modules/io/src/img/map_io_mrc_handler.cc b/modules/io/src/img/map_io_mrc_handler.cc index 80ee60250..924af5c13 100644 --- a/modules/io/src/img/map_io_mrc_handler.cc +++ b/modules/io/src/img/map_io_mrc_handler.cc @@ -1003,10 +1003,10 @@ bool MapIOMrcHandler::MatchType(const ImageFormatBase& type) return false; } -bool MapIOMrcHandler::MatchSuffix(const boost::filesystem::path& loc) +bool MapIOMrcHandler::MatchSuffix(const String& loc) { - if(detail::FilenameEndsWith(loc.string(),".mrc") || detail::FilenameEndsWith(loc.string(),".map") || - detail::FilenameEndsWith(loc.string(),".ccp4") || detail::FilenameEndsWith(loc.string(),".map.gz")) { + if(detail::FilenameEndsWith(loc,".mrc") || detail::FilenameEndsWith(loc,".map") || + detail::FilenameEndsWith(loc,".ccp4") || detail::FilenameEndsWith(loc,".map.gz")) { return true; } return false; diff --git a/modules/io/src/img/map_io_mrc_handler.hh b/modules/io/src/img/map_io_mrc_handler.hh index 76a6b9d36..673fac913 100644 --- a/modules/io/src/img/map_io_mrc_handler.hh +++ b/modules/io/src/img/map_io_mrc_handler.hh @@ -74,7 +74,7 @@ public: virtual void Export(const img::MapHandle& sh, std::ostream& loc,const ImageFormatBase& formatstruct) const; static bool MatchContent(unsigned char* header); static bool MatchType(const ImageFormatBase& type); - static bool MatchSuffix(const boost::filesystem::path& loc); + static bool MatchSuffix(const String& loc); static String GetFormatName() { return String("Mrc"); }; static String GetFormatDescription() { return String("Format used by the MRC software package"); }; diff --git a/modules/io/src/img/map_io_nanoscope_handler.cc b/modules/io/src/img/map_io_nanoscope_handler.cc index 32ce6ccd1..0019fa320 100644 --- a/modules/io/src/img/map_io_nanoscope_handler.cc +++ b/modules/io/src/img/map_io_nanoscope_handler.cc @@ -234,9 +234,9 @@ bool MapIONanoscopeHandler::MatchType(const ImageFormatBase& type) return false; } -bool MapIONanoscopeHandler::MatchSuffix(const boost::filesystem::path& loc) +bool MapIONanoscopeHandler::MatchSuffix(const String& loc) { - if(detail::FilenameEndsWith(loc.string(),".mod") ) { + if(detail::FilenameEndsWith(loc,".mod") ) { return true; } return false; diff --git a/modules/io/src/img/map_io_nanoscope_handler.hh b/modules/io/src/img/map_io_nanoscope_handler.hh index 675889769..99a457a1a 100644 --- a/modules/io/src/img/map_io_nanoscope_handler.hh +++ b/modules/io/src/img/map_io_nanoscope_handler.hh @@ -57,7 +57,7 @@ public: virtual void Export(const img::MapHandle& sh, std::ostream& loc,const ImageFormatBase& formatstruct) const; static bool MatchContent(unsigned char* header); static bool MatchType(const ImageFormatBase& type); - static bool MatchSuffix(const boost::filesystem::path& loc); + static bool MatchSuffix(const String& loc); static String GetFormatName() { return String("Nanoscope"); } static String GetFormatDescription() { return String("Format used by software from Veeco"); } }; diff --git a/modules/io/src/img/map_io_png_handler.cc b/modules/io/src/img/map_io_png_handler.cc index 38d88be66..84b290d2e 100644 --- a/modules/io/src/img/map_io_png_handler.cc +++ b/modules/io/src/img/map_io_png_handler.cc @@ -311,9 +311,9 @@ bool MapIOPngHandler::MatchType(const ImageFormatBase& type) } return false; } -bool MapIOPngHandler::MatchSuffix(const boost::filesystem::path& loc) +bool MapIOPngHandler::MatchSuffix(const String& loc) { - if(detail::FilenameEndsWith(loc.string(),".png") ) { + if(detail::FilenameEndsWith(loc,".png") ) { return true; } return false; diff --git a/modules/io/src/img/map_io_png_handler.hh b/modules/io/src/img/map_io_png_handler.hh index d5267a6da..156d684d4 100644 --- a/modules/io/src/img/map_io_png_handler.hh +++ b/modules/io/src/img/map_io_png_handler.hh @@ -52,7 +52,7 @@ public: virtual void Export(const img::MapHandle& sh, std::ostream& loc,const ImageFormatBase& formatstruct) const; static bool MatchContent(unsigned char* header); static bool MatchType(const ImageFormatBase& type); - static bool MatchSuffix(const boost::filesystem::path& loc); + static bool MatchSuffix(const String& loc); static String GetFormatName() { return String("Png");} static String GetFormatDescription() { return String("Portable Network Graphic image format");} }; diff --git a/modules/io/src/img/map_io_situs_handler.cc b/modules/io/src/img/map_io_situs_handler.cc index f31444b30..a7e12da30 100644 --- a/modules/io/src/img/map_io_situs_handler.cc +++ b/modules/io/src/img/map_io_situs_handler.cc @@ -272,9 +272,9 @@ bool MapIOSitusHandler::MatchType(const ImageFormatBase& type) return false; } -bool MapIOSitusHandler::MatchSuffix(const boost::filesystem::path& loc) +bool MapIOSitusHandler::MatchSuffix(const String& loc) { - if(detail::FilenameEndsWith(loc.string(),".situs") || detail::FilenameEndsWith(loc.string(),".sit") ) { + if(detail::FilenameEndsWith(loc,".situs") || detail::FilenameEndsWith(loc,".sit") ) { return true; } return false; diff --git a/modules/io/src/img/map_io_situs_handler.hh b/modules/io/src/img/map_io_situs_handler.hh index a5d64a727..f3e3d6b78 100644 --- a/modules/io/src/img/map_io_situs_handler.hh +++ b/modules/io/src/img/map_io_situs_handler.hh @@ -54,7 +54,7 @@ class DLLEXPORT_OST_IO MapIOSitusHandler: public MapIOHandler virtual void Export(const img::MapHandle& sh, std::ostream& loc,const ImageFormatBase& formatstruct) const; static bool MatchContent(unsigned char* header); static bool MatchType(const ImageFormatBase& type); - static bool MatchSuffix(const boost::filesystem::path& loc); + static bool MatchSuffix(const String& loc); static String GetFormatName() { return "Situs"; }; static String GetFormatDescription() { return "Format used by the Situs software package"; }; }; diff --git a/modules/io/src/img/map_io_spi_handler.cc b/modules/io/src/img/map_io_spi_handler.cc index 6e10c30cc..63b5e1e4c 100644 --- a/modules/io/src/img/map_io_spi_handler.cc +++ b/modules/io/src/img/map_io_spi_handler.cc @@ -512,9 +512,9 @@ bool MapIOSpiHandler::MatchType(const ImageFormatBase& type) } return false; } -bool MapIOSpiHandler::MatchSuffix(const boost::filesystem::path& loc) +bool MapIOSpiHandler::MatchSuffix(const String& loc) { - if (detail::FilenameEndsWith(loc.string(),".spi") ) { + if (detail::FilenameEndsWith(loc,".spi") ) { return true; } return false; diff --git a/modules/io/src/img/map_io_spi_handler.hh b/modules/io/src/img/map_io_spi_handler.hh index df2d61526..ac62117b1 100644 --- a/modules/io/src/img/map_io_spi_handler.hh +++ b/modules/io/src/img/map_io_spi_handler.hh @@ -64,7 +64,7 @@ class DLLEXPORT_OST_IO MapIOSpiHandler: public MapIOHandler virtual void Export(const img::MapHandle& sh, std::ostream& loc,const ImageFormatBase& formatstruct) const; static bool MatchContent(unsigned char* header); static bool MatchType(const ImageFormatBase& type); - static bool MatchSuffix(const boost::filesystem::path& loc); + static bool MatchSuffix(const String& loc); static String GetFormatName() { return String("Spider"); }; static String GetFormatDescription() { return String("Format sued by the Spider software package"); }; diff --git a/modules/io/src/img/map_io_tiff_handler.cc b/modules/io/src/img/map_io_tiff_handler.cc index 863013dd0..233a43c2d 100644 --- a/modules/io/src/img/map_io_tiff_handler.cc +++ b/modules/io/src/img/map_io_tiff_handler.cc @@ -427,9 +427,9 @@ bool MapIOTiffHandler::MatchType(const ImageFormatBase& type) return (type.GetFormatString()=="defined_tiff"); } -bool MapIOTiffHandler::MatchSuffix(const boost::filesystem::path& loc) +bool MapIOTiffHandler::MatchSuffix(const String& loc) { - return (detail::FilenameEndsWith(loc.string(),".tif") || detail::FilenameEndsWith(loc.string(),".tiff") ); + return (detail::FilenameEndsWith(loc,".tif") || detail::FilenameEndsWith(loc,".tiff") ); } diff --git a/modules/io/src/img/map_io_tiff_handler.hh b/modules/io/src/img/map_io_tiff_handler.hh index 8d9a9e3a6..7fbfb901e 100644 --- a/modules/io/src/img/map_io_tiff_handler.hh +++ b/modules/io/src/img/map_io_tiff_handler.hh @@ -90,7 +90,7 @@ class DLLEXPORT_OST_IO MapIOTiffHandler: public MapIOHandler virtual void Export(const img::MapHandle& sh, std::ostream& loc,const ImageFormatBase& formatstruct) const; static bool MatchContent(unsigned char* header); static bool MatchType(const ImageFormatBase& type); - static bool MatchSuffix(const boost::filesystem::path& loc); + static bool MatchSuffix(const String& loc); static String GetFormatName() { return String( "Tiff"); } static String GetFormatDescription() { return String("Tagged Image File Format"); } diff --git a/modules/io/src/io_manager.cc b/modules/io/src/io_manager.cc index d64358ffa..88451aeed 100644 --- a/modules/io/src/io_manager.cc +++ b/modules/io/src/io_manager.cc @@ -140,13 +140,14 @@ MapIOHandlerPtr IOManager::FindMapImportHandlerFile(const boost::filesystem::pat } throw IOException("Unsupported type in FindMapImportHandle."); }else{ - for(MapIOFList::const_iterator it=map_io_list_.begin(); it!=map_io_list_.end();++it) { - if((*it)->MatchSuffix(loc)) { + String match_suf_string=loc.string(); + std::transform(match_suf_string.begin(),match_suf_string.end(),match_suf_string.begin(),tolower); + for(MapIOFList::const_iterator it=map_io_list_.begin(); it!=map_io_list_.end();++it) { + if((*it)->MatchSuffix(match_suf_string)) { return (*it)->Create(); } } unsigned char header[256]; - boost::filesystem::ifstream infile(loc, std::ios::binary); if(!infile) { @@ -206,8 +207,10 @@ MapIOHandlerPtr IOManager::FindMapExportHandlerFile(const boost::filesystem::pat if (pos == String::npos){ throw IOException("No file suffix given for " + filename+", please indicate file type."); } + String match_suf_string=loc.string(); + std::transform(match_suf_string.begin(),match_suf_string.end(),match_suf_string.begin(),tolower); for(MapIOFList::const_iterator it=map_io_list_.begin(); it!=map_io_list_.end();++it) { - if((*it)->MatchSuffix(loc)) { + if((*it)->MatchSuffix(match_suf_string)) { return(*it)->Create(); } } -- GitLab