From 6c5f557d0a84287eec21b30e002973c76ad14bc0 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Wed, 16 Dec 2015 21:43:48 +0100 Subject: [PATCH] Updated ctool.cpp to run in the latest GFilename scheme Integrate code --- src/support/ctool.cpp | 48 ++++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/src/support/ctool.cpp b/src/support/ctool.cpp index 35b5267..9efd517 100644 --- a/src/support/ctool.cpp +++ b/src/support/ctool.cpp @@ -414,26 +414,38 @@ GEbounds ctool::create_ebounds(void) // Get filename std::string ebinfile = (*this)["ebinfile"].filename(); - // Open energy boundary file using the EBOUNDS or ENERGYBINS - // extension. Throw an exception if opening fails. - GFits file(ebinfile); - if (file.contains("EBOUNDS")) { - file.close(); - ebounds.load(ebinfile,"EBOUNDS"); - } - else if (file.contains("ENERGYBINS")) { - file.close(); - ebounds.load(ebinfile,"ENERGYBINS"); + // Create filename instance + GFilename fname(ebinfile); + + // Check if extension name was provided + if (!fname.has_extname()) { + + // Open energy boundary file using the EBOUNDS or ENERGYBINS + // extension. Throw an exception if opening fails. + GFits file(ebinfile); + if (file.contains("EBOUNDS")) { + file.close(); + ebounds.load(ebinfile); + } + else if (file.contains("ENERGYBINS")) { + file.close(); + ebinfile += "[ENERGYBINS]"; + ebounds.load(ebinfile); + } + else { + file.close(); + std::string msg = "No extension with name \"EBOUNDS\" or" + " \"ENERGYBINS\" found in FITS file" + " \""+ebinfile+"\".\n" + "An \"EBOUNDS\" or \"ENERGYBINS\" extension" + " is required if the parameter \"ebinalg\"" + " is set to \"FILE\"."; + throw GException::invalid_value(G_CREATE_EBOUNDS, msg); + } } else { - file.close(); - std::string msg = "No extension with name \"EBOUNDS\" or" - " \"ENERGYBINS\" found in FITS file" - " \""+ebinfile+"\".\n" - "An \"EBOUNDS\" or \"ENERGYBINS\" extension" - " is required if the parameter \"ebinalg\"" - " is set to \"FILE\"."; - throw GException::invalid_value(G_CREATE_EBOUNDS, msg); + // Load ebounds from filename including extension + ebounds.load(ebinfile); } } // endif: ebinalg was "FILE" -- libgit2 0.21.4