Fix bug with absolute meshdirs in included XML files. Fixes #1772.

PiperOrigin-RevId: 649150979
Change-Id: I5df08c689afc4f5bc625e989a8c0b9733fcfa3c2
This commit is contained in:
Kyle Bayes
2024-07-03 11:48:13 -07:00
committed by Copybara-Service
parent 9107d3b507
commit 2a4410e4e5
8 changed files with 75 additions and 45 deletions
+18 -11
View File
@@ -837,23 +837,30 @@ bool mjuu_isabspath(string path) {
// assemble full filename
string mjuu_makefullname(string filedir, string meshdir, string filename) {
// filename has absolute path: filename
if (mjuu_isabspath(filename)) {
return filename;
// assemble two file paths
std::string mjuu_combinePaths(const string& path1, const string& path2) {
// path2 has absolute path
if (mjuu_isabspath(path2)) {
return path2;
}
// meshdir has absolute path: meshdir + filename
if (mjuu_isabspath(meshdir)) {
return meshdir + filename;
std::size_t n = path1.size();
if (n > 0 && path1[n - 1] != '\\' && path1[n - 1] != '/') {
return path1 + "/" + path2;
}
// default
return filedir + meshdir + filename;
return path1 + path2;
}
// assemble three file paths
std::string mjuu_combinePaths(const string& path1, const string& path2,
const string& path3) {
return mjuu_combinePaths(path1, mjuu_combinePaths(path2, path3));
}
// return true if the text is in a valid content type format:
// {type}/{subtype}[;{parameter}={value}]
static bool mjuu_isValidContentType(std::string_view text) {