@@ -196,24 +196,20 @@ Library::Error Library::load(const char exename[], const char path[], bool debug
196196
197197 const bool is_abs_path = Path::isAbsolute (path);
198198
199+ std::string fullfilename (path);
200+
201+ // TODO: what if the extension is not .cfg?
202+ // only append extension when we provide the library name and not a path - TODO: handle relative paths?
203+ if (!is_abs_path && Path::getFilenameExtension (fullfilename).empty ())
204+ fullfilename += " .cfg" ;
205+
199206 std::string absolute_path;
200207 // open file..
201208 tinyxml2::XMLDocument doc;
202209 if (debug)
203- std::cout << " looking for library '" + std::string (path) + " '" << std::endl;
204- tinyxml2::XMLError error = xml_LoadFile (doc, path );
210+ std::cout << " looking for library '" + fullfilename + " '" << std::endl;
211+ tinyxml2::XMLError error = xml_LoadFile (doc, fullfilename. c_str () );
205212 if (error == tinyxml2::XML_ERROR_FILE_NOT_FOUND ) {
206- // failed to open file.. is there no extension?
207- std::string fullfilename (path);
208- if (Path::getFilenameExtension (fullfilename).empty ()) {
209- fullfilename += " .cfg" ;
210- if (debug)
211- std::cout << " looking for library '" + fullfilename + " '" << std::endl;
212- error = xml_LoadFile (doc, fullfilename.c_str ());
213- if (error != tinyxml2::XML_ERROR_FILE_NOT_FOUND )
214- absolute_path = Path::getAbsoluteFilePath (fullfilename);
215- }
216-
217213 // only perform further lookups when the given path was not absolute
218214 if (!is_abs_path && error == tinyxml2::XML_ERROR_FILE_NOT_FOUND )
219215 {
0 commit comments