From 47834895ee8284b3e42c1436c1bb59c36fab5051 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 15 Jan 2019 16:13:40 +0100 Subject: Use C++ OString/OUString classes here ...instead of underlying C structs Change-Id: I25f1de9a902e5d8ed459c9b1bfc8a8c855eefb2d Reviewed-on: https://gerrit.libreoffice.org/66394 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- sal/osl/unx/security.cxx | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) (limited to 'sal/osl') diff --git a/sal/osl/unx/security.cxx b/sal/osl/unx/security.cxx index 3ea5c96b7bdd..c440de1bf3e1 100644 --- a/sal/osl/unx/security.cxx +++ b/sal/osl/unx/security.cxx @@ -32,7 +32,7 @@ #include "system.hxx" #include -#include +#include #include #include @@ -267,28 +267,18 @@ static bool osl_psz_getHomeDir(oslSecurity Security, sal_Char* pszDirectory, sal #ifdef ANDROID { sal_Bool bRet = sal_False; - rtl_uString *pName = 0, *pValue = 0; + OUString pValue; - rtl_uString_newFromAscii(&pName, "HOME"); - - if (rtl_bootstrap_get(pName, &pValue, NULL)) + if (rtl::Bootstrap::get("HOME", pValue)) { - rtl_String *pStrValue = 0; - if (pValue && pValue->length > 0) + auto const pStrValue = OUStringToOString(pValue, RTL_TEXTENCODING_UTF8); + if (!pStrValue.isEmpty()) { - rtl_uString2String(&pStrValue, pValue->buffer, - pValue->length, RTL_TEXTENCODING_UTF8, - OUSTRING_TO_OSTRING_CVTFLAGS); - if (pStrValue && pStrValue->length > 0) - { - sal_Int32 nCopy = (sal_Int32)std::min(nMax-1, pStrValue->length) ; - strncpy (pszDirectory, pStrValue->buffer, nCopy); - pszDirectory[nCopy] = '\0'; - bRet = (std::size_t)pStrValue->length < nMax; - } - rtl_string_release(pStrValue); + sal_Int32 nCopy = (sal_Int32)std::min(nMax-1, pStrValue.getLength()) ; + strncpy (pszDirectory, pStrValue.getStr(), nCopy); + pszDirectory[nCopy] = '\0'; + bRet = (std::size_t)pStrValue.getLength() < nMax; } - rtl_uString_release(pName); } if (bRet) return bRet; -- cgit