//***************************************************************************** //*** f_WorkspacePathFromSWS.pkg //*** //*** Author: Ben Weijers //*** Data Access Europe //*** February 2006 //*** //*** Purpose: //*** Implements a function to get the path to the WS file from a given SWS //*** file. //***************************************************************************** Use cIniFile.pkg Use cWorkspace.pkg External_Function GetLongPathName "GetLongPathNameA" Kernel32.dll ; Pointer lpsShortFileName ; Pointer lpsLongFileName ; Integer iBufferSize ; Returns DWord Function WorkspacePathFromSWS Global String sSWSPath Returns String Handle hoIniFile Integer iLongPathLength String sSWSLongPath String sWSPath String sCurDir // Make sure we use a long path name Move (GetLongPathName(Addressof(sSWSPath), 0, 0)) To iLongPathLength If (iLongPathLength > 0) Begin Move (Repeat(Character(0), iLongPathLength + 1)) To sSWSLongPath Move (GetLongPathName(Addressof(sSWSPath), Addressof(sSWSLongPath), iLongPathLength + 1)) To iLongPathLength End Else ; Move sSWSPath To sSWSLongPath // Now get the path to the ws file Get Create U_cIniFile To hoIniFile If (hoIniFile <> 0) Begin Set psFileName Of hoIniFile To sSWSLongPath Get ReadString Of hoIniFile 'WorkspacePaths' 'ConfigFile' "" To sWSPath Send Destroy Of hoIniFile End If (sWSPath <> "") Begin Move ("." - Sysconf(SYSCONF_DIR_SEPARATOR)) To sCurDir If (Left(sWSPath, Length(sCurDir)) = sCurDir) ; Move (ExtractFilePath(sSWSLongPath) - Right(sWSPath, Length(sWSPath) - Length(sCurDir))) To sWSPath End Function_Return sWSPath End_Function // WorkspacePathFromSWS