diff --git a/Testing/Code/IO/otbMultiDatasetReadingInfo.cxx b/Testing/Code/IO/otbMultiDatasetReadingInfo.cxx index c0be78f002d95edf9036c396837260738724b20f..6bbfa02f47f5ed14e55022136e3cad83433acba6 100644 --- a/Testing/Code/IO/otbMultiDatasetReadingInfo.cxx +++ b/Testing/Code/IO/otbMultiDatasetReadingInfo.cxx @@ -19,6 +19,7 @@ #include <iostream> #include <fstream> #include <string> +#include "base/ossimFilename.h" #include "otbGDALImageIO.h" @@ -50,15 +51,30 @@ int otbMultiDatasetReadingInfo(int argc, char* argv[]) if (readingSubDatasetInfo == false ) return EXIT_FAILURE; + // Parse all the names to delete the path of the filename + for( unsigned int itSubDataset = 0; itSubDataset < (unsigned int)names.size(); itSubDataset++ ) + { + std::size_t posDeb = names[itSubDataset].find(":\""); + if (posDeb==std::string::npos) + return EXIT_FAILURE; + + std::size_t posEnd = names[itSubDataset].rfind("\":"); + if (posEnd==std::string::npos) + return EXIT_FAILURE; + + // Remove the path from the SubDataset_name metadata + std::string strFilepath = names[itSubDataset].substr(posDeb+2, posEnd - posDeb - 2); + ossimFilename lFile = ossimFilename(strFilepath); + names[itSubDataset].replace(posDeb+2, posEnd - posDeb - 2, (lFile.file()).c_str() ); + } + std::ofstream file; file.open(outputAsciiFilename); - for( unsigned int itSubDataset = 0; itSubDataset < names.size(); itSubDataset++ ) + for( unsigned int itSubDataset = 0; itSubDataset < (unsigned int)names.size(); itSubDataset++ ) { - file << "NAME_"<< itSubDataset+1 << " :" << names[itSubDataset] <<std::endl; - //std::cout << "NAME_"<< itSubDataset+1 << " :" << names[itSubDataset] <<std::endl; - file << "DESC_" << itSubDataset+1 << " :" << desc[itSubDataset] <<std::endl; - //std::cout << "DESC_"<< itSubDataset+1 << " :" << desc[itSubDataset] <<std::endl; + file << "NAME_" << itSubDataset+1 << " :" << names[itSubDataset] << std::endl; + file << "DESC_" << itSubDataset+1 << " :" << desc[itSubDataset] << std::endl; } file.close();