Browse Source

be more lenient of case check--allow 8.3 filenames

David Rose 20 years ago
parent
commit
a641f3d0cb
1 changed files with 18 additions and 1 deletions
  1. 18 1
      dtool/src/dtoolutil/filename.cxx

+ 18 - 1
dtool/src/dtoolutil/filename.cxx

@@ -862,7 +862,24 @@ make_true_case() {
   }
   }
   assert(l < MAX_PATH + 1);
   assert(l < MAX_PATH + 1);
 
 
-  (*this) = Filename::from_os_specific(long_name);
+  Filename true_case = Filename::from_os_specific(long_name);
+		  
+  // Now sanity-check the true-case filename.  If it's not the same as
+  // the source file, except for case, reject it.
+  string orig_filename = get_fullpath();
+  string new_filename = true_case.get_fullpath();
+  bool match = (orig_filename.length() == new_filename.length());
+  for (size_t i = 0; i < orig_filename.length() && match; ++i) {
+    match = (tolower(orig_filename[i]) == tolower(new_filename[i]));
+  }
+  if (!match) {
+    // Something went wrong.  Keep the original filename, assume it
+    // was the correct case after all.  We return true because the
+    // filename is good.
+    return true;
+  }
+
+  (*this) = true_case;
   return true;
   return true;
 
 
 #else  // WIN32
 #else  // WIN32