From b91e601442d983e76c63bb54039193e9f35e94d8 Mon Sep 17 00:00:00 2001 From: vro Date: Fri, 18 Feb 2022 18:08:24 +0300 Subject: [PATCH] 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. 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 | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/CDF/CDF_Store.cxx b/src/CDF/CDF_Store.cxx index 197e312453..78260c2245 100644 --- a/src/CDF/CDF_Store.cxx +++ b/src/CDF/CDF_Store.cxx @@ -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(); + Standard_Integer aLen = 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 - } + // 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);