diff options
author | Oliver Braun <obr@openoffice.org> | 2001-05-11 18:20:10 +0000 |
---|---|---|
committer | Oliver Braun <obr@openoffice.org> | 2001-05-11 18:20:10 +0000 |
commit | d63363bedad11a19be6e35f32b7d6ae88011d623 (patch) | |
tree | f258e62fc74530ae2b4fa3f5eb250d6b75563987 /sal | |
parent | 704b80a1f9b0271184968c67434dcd9dfe821867 (diff) |
TF_FILEURL
Diffstat (limited to 'sal')
-rw-r--r-- | sal/osl/unx/module.c | 45 | ||||
-rw-r--r-- | sal/osl/unx/process.c | 62 | ||||
-rw-r--r-- | sal/osl/unx/profile.c | 103 |
3 files changed, 62 insertions, 148 deletions
diff --git a/sal/osl/unx/module.c b/sal/osl/unx/module.c index 1e5a578e1602..5b9364880ec6 100644 --- a/sal/osl/unx/module.c +++ b/sal/osl/unx/module.c @@ -2,9 +2,9 @@ * * $RCSfile: module.c,v $ * - * $Revision: 1.15 $ + * $Revision: 1.16 $ * - * last change: $Author: svesik $ $Date: 2001-04-26 14:53:29 $ + * last change: $Author: obr $ $Date: 2001-05-11 19:20:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -75,6 +75,10 @@ #include <osl/thread.h> #endif +#ifndef _OSL_FILE_H_ +#include <osl/file.h> +#endif + #include "system.h" #if defined(DEBUG) @@ -90,6 +94,9 @@ extern oslProcessError SAL_CALL osl_searchPath(const sal_Char* pszName, const sa extern int _dlclose(void *handle); #endif /* MACOSX */ +/* implemented in file.c */ +extern UnicodeToText( char *, size_t, const sal_Unicode *, sal_Int32 ); + oslModule SAL_CALL osl_psz_loadModule(const sal_Char *pszModuleName, sal_Int32 nRtldMode); void* SAL_CALL osl_psz_getSymbol(oslModule hModule, const sal_Char* pszSymbolName); @@ -101,36 +108,30 @@ void* SAL_CALL osl_psz_getSymbol(oslModule hModule, const sal_Char* pszSymbolNam oslModule SAL_CALL osl_loadModule(rtl_uString *ustrModuleName, sal_Int32 nRtldMode) { oslModule pModule=0; + rtl_uString* ustrTmp = NULL; OSL_ENSURE(ustrModuleName,"osl_loadModule : string is not valid"); - if ( ustrModuleName != 0 ) - { - rtl_String* strModuleName = 0; - sal_Char* pszModuleName=0; - - rtl_uString2String( &strModuleName, - rtl_uString_getStr(ustrModuleName), - rtl_uString_getLength(ustrModuleName), - osl_getThreadTextEncoding(), - OUSTRING_TO_OSTRING_CVTFLAGS ); - - pszModuleName=rtl_string_getStr(strModuleName); + /* ensure ustrTmp hold valid string */ + if( osl_File_E_None != osl_getSystemPathFromFileURL( ustrModuleName, &ustrTmp ) ) + rtl_uString_assign( &ustrTmp, ustrModuleName ); -#if defined(DEBUG) - fprintf(stderr,"osl_loadModule : lib to load : [%s]\n",pszModuleName); -#endif - - if ( strncmp(pszModuleName,"//./",4) == 0 ) - pszModuleName+=3; + if( ustrTmp ) + { + char *buffer[PATH_MAX]; - pModule = osl_psz_loadModule(pszModuleName,nRtldMode); - rtl_string_release(strModuleName); + if( UnicodeToText( buffer, PATH_MAX, ustrTmp->buffer, ustrTmp->length ) ) + pModule = osl_psz_loadModule( buffer, nRtldMode ); } + rtl_uString_release( ustrTmp ); + return pModule; } +/*****************************************************************************/ +/* osl_psz_loadModule */ +/*****************************************************************************/ oslModule SAL_CALL osl_psz_loadModule(const sal_Char *pszModuleName, sal_Int32 nRtldMode) { diff --git a/sal/osl/unx/process.c b/sal/osl/unx/process.c index 5bc4ef9b0757..be2e058eeb78 100644 --- a/sal/osl/unx/process.c +++ b/sal/osl/unx/process.c @@ -2,9 +2,9 @@ * * $RCSfile: process.c,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: mfe $ $Date: 2001-03-22 10:01:41 $ + * last change: $Author: obr $ $Date: 2001-05-11 19:20:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -101,7 +101,8 @@ #define CONTROLLEN (sizeof(struct cmsghdr) + sizeof(int)) #endif - +/* implemented in file.c */ +extern oslFileError FileURLToPath( char *, size_t, rtl_uString* ); /****************************************************************************** * @@ -386,33 +387,25 @@ static sal_Char *getCmdLine() #endif -oslProcessError SAL_CALL osl_getExecutableFile(rtl_uString **ustrFile) +oslProcessError SAL_CALL osl_getExecutableFile( rtl_uString** pustrFile ) { - sal_Char pszExecutable[PATH_MAX]; - sal_Char pszUncPath[PATH_MAX+5]; - oslProcessError Error; - - pszExecutable[0] = '\0'; - pszUncPath[0] = '\0'; + char executablePath[PATH_MAX] = ""; + oslProcessError eRet; - Error=osl_psz_getExecutableFile(pszExecutable,sizeof(pszExecutable)); + eRet = osl_psz_getExecutableFile( executablePath, PATH_MAX ); - if ( Error == osl_Process_E_None) + if ( eRet == osl_Process_E_None) { - strcpy(pszUncPath,"//."); - strcat(pszUncPath,pszExecutable); - } + rtl_uString *ustrTmp = NULL; - /* fprintf(stderr,"Exec file is '%s'\n",pszUncPath);*/ + rtl_string2UString( &ustrTmp, executablePath, strlen( executablePath ), + osl_getThreadTextEncoding(), OUSTRING_TO_OSTRING_CVTFLAGS ); - rtl_string2UString( - ustrFile, - pszUncPath, - rtl_str_getLength( pszUncPath ), - osl_getThreadTextEncoding(), - OUSTRING_TO_OSTRING_CVTFLAGS ); + osl_getFileURLFromSystemPath( ustrTmp, pustrFile ); + rtl_uString_release( ustrTmp ); + } - return Error; + return eRet; } @@ -967,26 +960,16 @@ oslProcessError SAL_CALL osl_executeProcess(rtl_uString *ustrImageName, oslProcessError Error; rtl_String* strImageName=0; rtl_String* strWorkDir=0; - sal_Char* pszImageName=0; sal_Char* pszWorkDir=0; sal_Char** pArguments=0; sal_Char** pEnvironment=0; unsigned int index; + char imagePath[PATH_MAX] = ""; - if ( ustrImageName != 0 && ustrImageName->buffer[0] != 0 ) + if ( ustrImageName && ustrImageName->length ) { - rtl_uString2String( &strImageName, - rtl_uString_getStr(ustrImageName), - rtl_uString_getLength(ustrImageName), - osl_getThreadTextEncoding(), - OUSTRING_TO_OSTRING_CVTFLAGS ); - - pszImageName = rtl_string_getStr(strImageName); - if ( strncmp(pszImageName,"//./",4) == 0 ) - { - pszImageName+=3; - } + FileURLToPath( imagePath, PATH_MAX, ustrImageName ); } if ( ustrWorkDir != 0 && ustrWorkDir->buffer[0] != 0 ) @@ -1043,7 +1026,7 @@ oslProcessError SAL_CALL osl_executeProcess(rtl_uString *ustrImageName, } - Error = osl_psz_executeProcess(pszImageName, + Error = osl_psz_executeProcess(imagePath, pArguments, Options, Security, @@ -1076,11 +1059,6 @@ oslProcessError SAL_CALL osl_executeProcess(rtl_uString *ustrImageName, free(pEnvironment); } - if ( strImageName != 0 ) - { - rtl_string_release(strImageName); - } - if ( strWorkDir != 0 ) { rtl_string_release(strWorkDir); diff --git a/sal/osl/unx/profile.c b/sal/osl/unx/profile.c index 2282294a48a6..970f3678a4b9 100644 --- a/sal/osl/unx/profile.c +++ b/sal/osl/unx/profile.c @@ -2,9 +2,9 @@ * * $RCSfile: profile.c,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: mfe $ $Date: 2001-02-26 16:17:49 $ + * last change: $Author: obr $ $Date: 2001-05-11 19:20:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -225,45 +225,20 @@ oslProcessError SAL_CALL osl_getCommandArgs(sal_Char* pszBuffer, sal_uInt32 Max) static sal_Bool bGlobalSofficeFlag=sal_False; +/* implemented in file.c */ +extern oslFileError FileURLToPath( char *, size_t, rtl_uString* ); /*****************************************************************************/ /* Exported Module Functions */ /*****************************************************************************/ oslProfile SAL_CALL osl_openProfile(rtl_uString *ustrProfileName, oslProfileOption Options) { - oslProfile pProfile=0; - rtl_String* strProfileName=0; - sal_Char* pszProfileName=0; - + char profilePath[PATH_MAX] = ""; if ( ustrProfileName != 0 && ustrProfileName->buffer[0] != 0 ) - { - - rtl_uString2String( &strProfileName, - rtl_uString_getStr(ustrProfileName), - rtl_uString_getLength(ustrProfileName), - osl_getThreadTextEncoding(), - OUSTRING_TO_OSTRING_CVTFLAGS ); - pszProfileName = rtl_string_getStr(strProfileName); - - if ( strncmp(pszProfileName,"//./",4) != 0 ) - { - rtl_string_release(strProfileName); - return 0; - } - pszProfileName+=3; - } - + FileURLToPath( profilePath, PATH_MAX, ustrProfileName ); - pProfile = osl_psz_openProfile(pszProfileName,Options); - - if ( strProfileName != 0 ) - { - rtl_string_release(strProfileName); - } - - - return pProfile; + return osl_psz_openProfile( profilePath,Options ); } @@ -1233,74 +1208,34 @@ sal_uInt32 SAL_CALL osl_getProfileSections(oslProfile Profile, sal_Char* pszBuff return (n); } -sal_Bool SAL_CALL osl_getProfileName(rtl_uString* ustrPath, rtl_uString* ustrName, rtl_uString** strProfileName) +sal_Bool SAL_CALL osl_getProfileName(rtl_uString* ustrPath, rtl_uString* ustrName, rtl_uString** pustrProfileName) { sal_Bool bRet=sal_False; - sal_Char pszBuffer[PATH_MAX]; - rtl_uString* strNativeName=0; - rtl_String* strPath=0; - rtl_String* strName=0; - sal_Char* pszPath=0; - sal_Char* pszName=0; - - pszBuffer[0] = '\0'; + sal_Char buffer[PATH_MAX] = ""; + rtl_uString* ustrTmp = NULL; + char path[PATH_MAX] = ""; + char name[PATH_MAX] = ""; if ( ustrPath != 0 && ustrPath->buffer[0] != 0 ) { - rtl_uString2String( &strPath, - rtl_uString_getStr(ustrPath), - rtl_uString_getLength(ustrPath), - osl_getThreadTextEncoding(), - OUSTRING_TO_OSTRING_CVTFLAGS ); - pszPath = rtl_string_getStr(strPath); - - /* Don't skip UNC prefix if metatag is used */ - - if ( strncmp(pszPath,"//./",4) == 0 ) - { - pszPath+=3; - } - else if ( strncmp(pszPath, "?", 1) != 0 ) - { - rtl_string_release(strPath); - return 0; - } + FileURLToPath( path, PATH_MAX, ustrPath ); } if ( ustrName != 0 && ustrName->buffer[0] != 0 ) { - rtl_uString2String( &strName, - rtl_uString_getStr(ustrName), - rtl_uString_getLength(ustrName), - osl_getThreadTextEncoding(), - OUSTRING_TO_OSTRING_CVTFLAGS ); - pszName = rtl_string_getStr(strName); + FileURLToPath( name, PATH_MAX, ustrName ); } + bRet = osl_psz_getProfileName( path, name, buffer, PATH_MAX ); - - bRet=osl_psz_getProfileName(pszPath,pszName,pszBuffer,sizeof(pszBuffer)); - - - if ( strPath != 0 ) + if( bRet ) { - rtl_string_release(strPath); + rtl_string2UString( &ustrTmp, buffer, strlen( buffer ), osl_getThreadTextEncoding(), OUSTRING_TO_OSTRING_CVTFLAGS ); + osl_getFileURLFromSystemPath( ustrTmp, pustrProfileName ); + rtl_uString_release( ustrTmp ); } - if ( strName != 0 ) - { - rtl_string_release(strName); - } - - /* Convert result to UNC notation */ - - rtl_string2UString( &strNativeName, pszBuffer, rtl_str_getLength( pszBuffer ), osl_getThreadTextEncoding(), OUSTRING_TO_OSTRING_CVTFLAGS ); - - osl_normalizePath( strNativeName, strProfileName ); - rtl_uString_release( strNativeName ); - - return bRet; } |