From: vro Date: Fri, 18 Feb 2022 15:08:24 +0000 (+0300) Subject: 0032785: Application Framework - CDF_Store::SetFolder incorrectly processes relative... X-Git-Tag: V7_7_0_beta~166 X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=b91e601442d983e76c63bb54039193e9f35e94d8;p=occt.git 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(). --- 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(); - - // 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);