Update of /cvsroot/jsbsim/JSBSim/src/input_output
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv24758/src/input_output
Modified Files:
FGModelLoader.cpp FGModelLoader.h FGOutputFile.cpp
FGOutputFile.h FGOutputTextFile.cpp FGOutputTextFile.h
FGScript.cpp FGScript.h FGXMLFileRead.h
Log Message:
JSBSim now uses SGPath to manage file names. It allows to use absolute paths, to use Unicode file names and to benefit from SimGear maintenance for the corresponding code.
Index: FGModelLoader.cpp
===================================================================
RCS file: /cvsroot/jsbsim/JSBSim/src/input_output/FGModelLoader.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** FGModelLoader.cpp 12 Jul 2015 12:41:55 -0000 1.3
--- FGModelLoader.cpp 25 Feb 2017 14:23:18 -0000 1.4
***************
*** 61,86 ****
if (!fname.empty()) {
FGXMLFileRead XMLFileRead;
! string file;
! try {
! file = model->FindFullPathName(fname);
! if (file.empty()) throw string("File does not exist.");
! }
! catch(string& e) {
! cerr << endl << el->ReadFrom()
! << "Could not open file: " << fname << endl << e << endl;
! return NULL;
! }
! if (CachedFiles.find(file) != CachedFiles.end())
! document = CachedFiles[file];
else {
! document = XMLFileRead.LoadXMLDocument(file);
if (document == 0L) {
cerr << endl << el->ReadFrom()
! << "Could not open file: " << file << endl;
return NULL;
}
! CachedFiles[file] = document;
}
--- 61,79 ----
if (!fname.empty()) {
FGXMLFileRead XMLFileRead;
! SGPath path(SGPath::fromLocal8Bit(fname.c_str()));
! if (path.isRelative())
! path = model->FindFullPathName(path);
! if (CachedFiles.find(path.utf8Str()) != CachedFiles.end())
! document = CachedFiles[path.utf8Str()];
else {
! document = XMLFileRead.LoadXMLDocument(path);
if (document == 0L) {
cerr << endl << el->ReadFrom()
! << "Could not open file: " << path << endl;
return NULL;
}
! CachedFiles[path.utf8Str()] = document;
}
***************
*** 94,111 ****
}
! //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
!
! string CheckFullPathName(const string& path, const string& fname)
! {
! string name = path + "/" + fname;
!
! if (name.length() <=4 || name.substr(name.length()-4, 4) != ".xml")
! name.append(".xml");
! ifstream file(name.c_str());
! if (!file.is_open())
! return string();
! return name;
}
}
--- 87,97 ----
}
! SGPath CheckPathName(const SGPath& path, const SGPath& filename) {
! SGPath fullName = path/filename.utf8Str();
! if (fullName.extension().empty())
! fullName.concat(".xml");
! return fullName.exists() ? fullName : SGPath();
}
}
Index: FGModelLoader.h
===================================================================
RCS file: /cvsroot/jsbsim/JSBSim/src/input_output/FGModelLoader.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** FGModelLoader.h 9 Jun 2014 11:52:06 -0000 1.1
--- FGModelLoader.h 25 Feb 2017 14:23:18 -0000 1.2
***************
*** 42,45 ****
--- 42,46 ----
#include "FGXMLElement.h"
+ #include "simgear/misc/sg_path.hxx"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
***************
*** 76,80 ****
};
! std::string CheckFullPathName(const std::string& path, const std::string& fname);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--- 77,81 ----
};
! SGPath CheckPathN |