]> OCCT Git - occt.git/commitdiff
0032785: Application Framework - CDF_Store::SetFolder incorrectly processes relative...
authorvro <vro@opencascade.com>
Fri, 18 Feb 2022 15:08:24 +0000 (18:08 +0300)
committersmoskvin <smoskvin@opencascade.com>
Tue, 22 Feb 2022 17:23:29 +0000 (20:23 +0300)
The code is simplified - it checks the last character and if it is a folder separator, it removes it.

Modified file:
- CDF_Store.cxx, the method SetFolder().

0032785: Application Framework - CDF_Store::SetFolder incorrectly processes relative paths on Linux

The code is simplified - it checks the last character and if it is a folder separator, it removes it.

Modified file:
- CDF_Store.cxx, the method SetFolder().

0032785: Application Framework - CDF_Store::SetFolder incorrectly processes relative paths on Linux

The code is simplified - it checks the last character and if it is a folder separator, it removes it.
// Also, variable 'l' is renamed to 'aLen'.
// And a check on the number of characters is added to avoid removal of the root folder ('/').

Modified file:
- CDF_Store.cxx, the method SetFolder().

src/CDF/CDF_Store.cxx

index 197e312453e1d9e031f9b6741316f29cd4b6dd96..78260c2245482c9c1818b14c2ce7eae1946c7cee 100644 (file)
@@ -78,19 +78,11 @@ Standard_Boolean  CDF_Store::SetFolder(const Standard_ExtString aFolder) {
 Standard_Boolean  CDF_Store::SetFolder(const TCollection_ExtendedString& aFolder) {
 
   TCollection_ExtendedString theFolder(aFolder);
-  Standard_Integer l = theFolder.Length();
-
-  // if the last character is the folder separator (which is always the first character)
-  // it is removed.
-       // This is correct for Unix systems but not for Windows! VMS and MAC? Thomas Haller, 23.11.01
-  if(l > 1) {
-#ifndef _WIN32
-    if(theFolder.Value(l) == theFolder.Value(1)) theFolder.Trunc(l-1);
-#else
-       if (theFolder.Value(l) == '/' || theFolder.Value(l) == '\\')
-               theFolder.Trunc(l-1);
-#endif
-  }
+  Standard_Integer aLen = theFolder.Length();
+
+  // if the last character is the folder separator, remove it.
+  if (aLen > 1 && (theFolder.Value(aLen) == '/' || theFolder.Value(aLen) == '\\'))
+    theFolder.Trunc(aLen-1);
 
   if(theMetaDataDriver->FindFolder(theFolder))  {
     myCurrentDocument->SetRequestedFolder(theFolder);