summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2021-04-20 16:06:27 +0200
committerStephan Bergmann <sbergman@redhat.com>2021-04-20 17:37:41 +0200
commit277554987fcd697c14f348f05e5e378d1db77ad5 (patch)
treeb0ad0fcec97f634ae425c72d26edf1e99d993da6 /sal
parent4c973093249bd6064f6e5675510dd1a2146581a1 (diff)
Simplify some code by using OUString instead of raw rtl_uString
Change-Id: I5a5dea23a466c0da12376f8b916b1a1b0eb0bd36 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114340 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sal')
-rw-r--r--sal/osl/unx/file_url.cxx26
1 files changed, 13 insertions, 13 deletions
diff --git a/sal/osl/unx/file_url.cxx b/sal/osl/unx/file_url.cxx
index d7fa6b5c3660..a738010f867b 100644
--- a/sal/osl/unx/file_url.cxx
+++ b/sal/osl/unx/file_url.cxx
@@ -369,23 +369,23 @@ oslFileError SAL_CALL osl_getSystemPathFromFileURL( rtl_uString *ustrFileURL, rt
oslFileError SAL_CALL osl_getFileURLFromSystemPath( rtl_uString *ustrSystemPath, rtl_uString **pustrFileURL )
{
- static const sal_Unicode pDoubleSlash[2] = { '/', '/' };
-
rtl_uString *pTmp = nullptr;
sal_Int32 nIndex;
- if( ustrSystemPath->length == 0 )
+ auto const & systemPath = OUString::unacquired(&ustrSystemPath);
+
+ if( systemPath.isEmpty() )
return osl_File_E_INVAL;
- if( rtl_ustr_ascii_shortenedCompare_WithLength( ustrSystemPath->buffer, ustrSystemPath->length,"file:", 5 ) == 0 )
+ if( systemPath.startsWith( "file:" ) )
return osl_File_E_INVAL;
/* check if system path starts with ~ or ~user and replace it with the appropriate home dir */
- if( ustrSystemPath->buffer[0] == '~' )
+ if( systemPath.startsWith("~") )
{
/* check if another user is specified */
- if( ( ustrSystemPath->length == 1 ) ||
- ( ustrSystemPath->buffer[1] == '/' ) )
+ if( ( systemPath.getLength() == 1 ) ||
+ ( systemPath[1] == '/' ) )
{
/* osl_getHomeDir returns file URL */
oslSecurity pSecurity = osl_getCurrentSecurity();
@@ -399,7 +399,7 @@ oslFileError SAL_CALL osl_getFileURLFromSystemPath( rtl_uString *ustrSystemPath,
rtl_uString_newFromStr_WithLength( &pTmp, pTmp->buffer + 7, pTmp->length - 7 );
/* replace '~' in original string */
- rtl_uString_newReplaceStrAt( &pTmp, ustrSystemPath, 0, 1, pTmp );
+ rtl_uString_newReplaceStrAt( &pTmp, systemPath.pData, 0, 1, pTmp );
}
else
{
@@ -409,18 +409,18 @@ oslFileError SAL_CALL osl_getFileURLFromSystemPath( rtl_uString *ustrSystemPath,
}
/* check if initial string contains repeated '/' characters */
- nIndex = rtl_ustr_indexOfStr_WithLength( ustrSystemPath->buffer, ustrSystemPath->length, pDoubleSlash, 2 );
+ nIndex = systemPath.indexOf( "//" );
if( nIndex != -1 )
{
sal_Int32 nSrcIndex;
sal_Int32 nDeleted = 0;
- /* if pTmp is not already allocated, copy ustrSystemPath for modification */
+ /* if pTmp is not already allocated, copy systemPath for modification */
if( pTmp == nullptr )
- rtl_uString_newFromString( &pTmp, ustrSystemPath );
+ rtl_uString_newFromString( &pTmp, systemPath.pData );
/* adapt index to pTmp */
- nIndex += pTmp->length - ustrSystemPath->length;
+ nIndex += pTmp->length - systemPath.getLength();
/* replace repeated '/' characters with a single '/' */
for( nSrcIndex = nIndex + 1; nSrcIndex < pTmp->length; nSrcIndex++ )
@@ -436,7 +436,7 @@ oslFileError SAL_CALL osl_getFileURLFromSystemPath( rtl_uString *ustrSystemPath,
}
if( pTmp == nullptr )
- rtl_uString_assign( &pTmp, ustrSystemPath );
+ rtl_uString_assign( &pTmp, systemPath.pData );
/* file URLs must be URI encoded */
rtl_uriEncode( pTmp, uriCharClass, rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8, pustrFileURL );