Use o3tl::{get,set}Environment instead of resp. osl_* functions

Simplifies the code, and avoids OUString internals access.
Also replace some getenv calls.

Change-Id: I5f7dc492fe87ea1fbaad6a61bc54e21f0f0c5aef
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187974
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski
2025-07-17 07:03:19 +02:00
parent bddeb8996a
commit 3a4961af43
29 changed files with 83 additions and 117 deletions
+2 -3
View File
@@ -35,6 +35,7 @@
#include <svl/zforlist.hxx>
#include <tools/urlobj.hxx>
#include <tools/fract.hxx>
#include <o3tl/environment.hxx>
#include <o3tl/temporary.hxx>
#include <osl/file.hxx>
#include <osl/process.h>
@@ -1132,9 +1133,7 @@ void SbRtl_Environ(StarBASIC *, SbxArray & rPar, bool)
if (rPar.Count() != 2)
return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
OUString aResult;
osl_getEnvironment(rPar.Get(1)->GetOUString().pData, &aResult.pData);
rPar.Get(0)->PutString(aResult);
rPar.Get(0)->PutString(o3tl::getEnvironment(rPar.Get(1)->GetOUString()));
}
static double GetDialogZoomFactor( bool bX, tools::Long nValue )
+2 -3
View File
@@ -39,6 +39,7 @@
#include <cppuhelper/implbase.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <cppuhelper/factory.hxx>
#include <o3tl/environment.hxx>
#include <o3tl/safeint.hxx>
#include <osl/file.hxx>
#include <osl/module.hxx>
@@ -1827,9 +1828,7 @@ void cppuhelper::ServiceManager::preloadImplementations() {
OUStringBuffer aMissingMsg;
/// Allow external callers & testers to disable certain components
if (OUString aDisable;
osl_getEnvironment(u"UNODISABLELIBRARY"_ustr.pData, &aDisable.pData) == osl_Process_E_None
&& !aDisable.isEmpty())
if (OUString aDisable = o3tl::getEnvironment(u"UNODISABLELIBRARY"_ustr); !aDisable.isEmpty())
{
for (sal_Int32 i = 0; i >= 0; )
{
+3 -3
View File
@@ -34,6 +34,7 @@
#include <com/sun/star/registry/XRegistryKey.hpp>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/shlib.hxx>
#include <o3tl/environment.hxx>
#include <o3tl/string_view.hxx>
#include <osl/module.hxx>
#include <osl/process.h>
@@ -52,9 +53,8 @@ css::uno::Environment cppuhelper::detail::getEnvironment(
{
OUString n(name);
if (!implementation.empty()) {
OUString imps;
if (osl_getEnvironment(u"UNO_ENV_LOG"_ustr.pData, &imps.pData) == osl_Process_E_None
&& !imps.isEmpty()) {
OUString imps = o3tl::getEnvironment(u"UNO_ENV_LOG"_ustr);
if (!imps.isEmpty()) {
for (sal_Int32 i = 0; i != -1;) {
std::u16string_view imp(o3tl::getToken(imps, 0, ';', i));
if (implementation == imp)
@@ -10,6 +10,7 @@
#include "dbtest_base.cxx"
#include <memory>
#include <o3tl/environment.hxx>
#include <osl/process.h>
#include <osl/time.h>
#include <rtl/ustrbuf.hxx>
@@ -81,9 +82,6 @@ class EmbeddedDBPerformanceTest
: public DBTestBase
{
private:
static constexpr OUString our_sEnableTestEnvVar = u"DBA_PERFTEST"_ustr;
// We store the results and print them at the end due to the amount of warning
// noise present which otherwise obscures the results.
OUStringBuffer m_aOutputBuffer;
@@ -143,10 +141,7 @@ void EmbeddedDBPerformanceTest::printTimes(
void EmbeddedDBPerformanceTest::testPerformance()
{
OUString sEnabled;
osl_getEnvironment(our_sEnableTestEnvVar.pData, &sEnabled.pData);
if (sEnabled.isEmpty())
if (o3tl::getEnvironment(u"DBA_PERFTEST"_ustr).isEmpty())
return;
m_aOutputBuffer.append("---------------------\n");
@@ -57,6 +57,7 @@
#include <cppuhelper/typeprovider.hxx>
#include <officecfg/Office/Common.hxx>
#include <comphelper/diagnose_ex.hxx>
#include <o3tl/environment.hxx>
#include <osl/diagnose.h>
#include <osl/process.h>
#include <sal/log.hxx>
@@ -544,10 +545,7 @@ Reference< XConnection > ODatabaseSource::buildLowLevelConnection(const OUString
if(!bIgnoreMigration && m_pImpl->m_sConnectURL == "sdbc:embedded:hsqldb")
{
Reference<XStorage> const xRootStorage = m_pImpl->getOrCreateRootStorage();
OUString sMigrEnvVal;
osl_getEnvironment(u"DBACCESS_HSQL_MIGRATION"_ustr.pData,
&sMigrEnvVal.pData);
if(!sMigrEnvVal.isEmpty())
if (!o3tl::getEnvironment(u"DBACCESS_HSQL_MIGRATION"_ustr).isEmpty())
bNeedMigration = true;
else
{
@@ -27,6 +27,7 @@
#include "GlowSoftEgdeShadowTools.hxx"
#ifdef DBG_UTIL
#include <o3tl/environment.hxx>
#include <tools/stream.hxx>
#include <vcl/filter/PngImageWriter.hxx>
#endif
@@ -223,8 +224,7 @@ void GlowPrimitive2D::create2DDecomposition(
if (bDoSaveForVisualControl)
{
// VCL_DUMP_BMP_PATH should be like C:/path/ or ~/path/
static const OUString sDumpPath(
OUString::createFromAscii(std::getenv("VCL_DUMP_BMP_PATH")));
static const OUString sDumpPath(o3tl::getEnvironment(u"VCL_DUMP_BMP_PATH"_ustr));
if (!sDumpPath.isEmpty())
{
SvFileStream aNew(sDumpPath + "test_glow.png", StreamMode::WRITE | StreamMode::TRUNC);
@@ -29,6 +29,7 @@
#include "GlowSoftEgdeShadowTools.hxx"
#ifdef DBG_UTIL
#include <o3tl/environment.hxx>
#include <tools/stream.hxx>
#include <vcl/filter/PngImageWriter.hxx>
#endif
@@ -259,8 +260,7 @@ void ShadowPrimitive2D::create2DDecomposition(
if (bDoSaveForVisualControl)
{
// VCL_DUMP_BMP_PATH should be like C:/path/ or ~/path/
static const OUString sDumpPath(
OUString::createFromAscii(std::getenv("VCL_DUMP_BMP_PATH")));
static const OUString sDumpPath(o3tl::getEnvironment(u"VCL_DUMP_BMP_PATH"_ustr));
if (!sDumpPath.isEmpty())
{
SvFileStream aNew(sDumpPath + "test_shadowblur.png",
@@ -27,6 +27,7 @@
#include "GlowSoftEgdeShadowTools.hxx"
#ifdef DBG_UTIL
#include <o3tl/environment.hxx>
#include <tools/stream.hxx>
#include <vcl/filter/PngImageWriter.hxx>
#endif
@@ -218,8 +219,7 @@ void SoftEdgePrimitive2D::create2DDecomposition(
if (bDoSaveForVisualControl)
{
// VCL_DUMP_BMP_PATH should be like C:/path/ or ~/path/
static const OUString sDumpPath(
OUString::createFromAscii(std::getenv("VCL_DUMP_BMP_PATH")));
static const OUString sDumpPath(o3tl::getEnvironment(u"VCL_DUMP_BMP_PATH"_ustr));
if (!sDumpPath.isEmpty())
{
SvFileStream aNew(sDumpPath + "test_softedge.png",
@@ -25,6 +25,7 @@
#include <basegfx/range/b2drange.hxx>
#ifdef DBG_UTIL
#include <o3tl/environment.hxx>
#include <tools/stream.hxx>
#include <vcl/filter/PngImageWriter.hxx>
#endif
@@ -260,8 +261,7 @@ bool prepareBitmapForDirectRender(
static bool bDoSaveForVisualControl(false); // loplugin:constvars:ignore
if (bDoSaveForVisualControl)
{
static const OUString sDumpPath(
OUString::createFromAscii(std::getenv("VCL_DUMP_BMP_PATH")));
static const OUString sDumpPath(o3tl::getEnvironment(u"VCL_DUMP_BMP_PATH"_ustr));
if (!sDumpPath.isEmpty())
{
SvFileStream aNew(sDumpPath + "test_getreplacement.png",
@@ -36,6 +36,7 @@
#include <mutex>
#ifdef DBG_UTIL
#include <o3tl/environment.hxx>
#include <tools/stream.hxx>
#endif
@@ -458,7 +459,7 @@ void impBufferDevice::paint(double fTrans)
#ifdef DBG_UTIL
// VCL_DUMP_BMP_PATH should be like C:/path/ or ~/path/
static bool bDoSaveForVisualControl(false); // loplugin:constvars:ignore
static const OUString sDumpPath(OUString::createFromAscii(std::getenv("VCL_DUMP_BMP_PATH")));
static const OUString sDumpPath(o3tl::getEnvironment(u"VCL_DUMP_BMP_PATH"_ustr));
if (!sDumpPath.isEmpty() && bDoSaveForVisualControl)
{
+3 -4
View File
@@ -32,6 +32,7 @@
#include <config_vclplug.h>
#ifdef DBG_UTIL
#include <o3tl/environment.hxx>
#include <tools/stream.hxx>
#include <vcl/dibtools.hxx>
#endif
@@ -250,8 +251,7 @@ BitmapEx convertToBitmapEx(drawinglayer::primitive2d::Primitive2DContainer&& rSe
if (bDoSaveForVisualControl)
{
// VCL_DUMP_BMP_PATH should be like C:/path/ or ~/path/
static const OUString sDumpPath(
OUString::createFromAscii(std::getenv("VCL_DUMP_BMP_PATH")));
static const OUString sDumpPath(o3tl::getEnvironment(u"VCL_DUMP_BMP_PATH"_ustr));
if (!sDumpPath.isEmpty())
{
SvFileStream aNew(sDumpPath + "test_content.bmp",
@@ -270,8 +270,7 @@ BitmapEx convertToBitmapEx(drawinglayer::primitive2d::Primitive2DContainer&& rSe
if (bDoSaveForVisualControl)
{
// VCL_DUMP_BMP_PATH should be like C:/path/ or ~/path/
static const OUString sDumpPath(
OUString::createFromAscii(std::getenv("VCL_DUMP_BMP_PATH")));
static const OUString sDumpPath(o3tl::getEnvironment(u"VCL_DUMP_BMP_PATH"_ustr));
if (!sDumpPath.isEmpty())
{
SvFileStream aNew(sDumpPath + "test_alpha.bmp", StreamMode::WRITE | StreamMode::TRUNC);
+2 -1
View File
@@ -22,6 +22,7 @@
#include <sal/log.hxx>
#include <osl/diagnose.h>
#include <vcl/dibtools.hxx>
#include <o3tl/environment.hxx>
#include <o3tl/safeint.hxx>
#include <o3tl/sprintf.hxx>
#include <tools/stream.hxx>
@@ -1612,7 +1613,7 @@ namespace emfio
if(bDoSaveForVisualControl)
{
// VCL_DUMP_BMP_PATH should be like C:/path/ or ~/path/
static const OUString sDumpPath(OUString::createFromAscii(std::getenv("VCL_DUMP_BMP_PATH")));
static const OUString sDumpPath(o3tl::getEnvironment(u"VCL_DUMP_BMP_PATH"_ustr));
if(!sDumpPath.isEmpty())
{
SvFileStream aNew(sDumpPath + "metafile_content.png",
@@ -25,6 +25,7 @@
#include <unotools/bootstrap.hxx>
#include <unotools/configmgr.hxx>
#include <o3tl/environment.hxx>
#include <osl/file.hxx>
#include <osl/process.h>
#include <osl/security.hxx>
@@ -300,10 +301,9 @@ OUString SubstitutePathVariables::GetHomeVariableValue()
OUString SubstitutePathVariables::GetPathVariableValue()
{
OUString aRetStr;
OUString aPathList;
OUString aPathList = o3tl::getEnvironment(u"PATH"_ustr);
if (osl_getEnvironment(u"PATH"_ustr.pData, &aPathList.pData) == osl_Process_E_None
&& !aPathList.isEmpty())
if (!aPathList.isEmpty())
{
const int PATH_EXTEND_FACTOR = 200;
OUString aTmp;
+5 -6
View File
@@ -29,6 +29,7 @@
#include <sal/log.hxx>
#include <salhelper/linkhelper.hxx>
#include <salhelper/thread.hxx>
#include <o3tl/environment.hxx>
#include <o3tl/string_view.hxx>
#include <memory>
#include <utility>
@@ -1038,9 +1039,8 @@ void addJavaInfosFromPath(
{
#if !defined JVM_ONE_PATH_CHECK
// Get Java from PATH environment variable
OUString usAllPath;
if (osl_getEnvironment(u"PATH"_ustr.pData, &usAllPath.pData) != osl_Process_E_None
|| usAllPath.isEmpty())
OUString usAllPath = o3tl::getEnvironment(u"PATH"_ustr);
if (usAllPath.isEmpty())
return;
sal_Int32 nIndex = 0;
@@ -1092,9 +1092,8 @@ void addJavaInfoFromJavaHome(
// variable. We set it in our build environment for build-time programs, though,
// so it is set when running unit tests that involve Java functionality. (Which affects
// at least CppunitTest_dbaccess_dialog_save, too, and not only the JunitTest ones.)
OUString sHome;
if (osl_getEnvironment(u"JAVA_HOME"_ustr.pData, &sHome.pData) == osl_Process_E_None
&& !sHome.isEmpty())
OUString sHome = o3tl::getEnvironment(u"JAVA_HOME"_ustr);
if (!sHome.isEmpty())
{
OUString sHomeUrl;
if(File::getFileURLFromSystemPath(sHome, sHomeUrl) == File::E_None)
+7 -9
View File
@@ -32,6 +32,7 @@
#include <osl/process.h>
#endif
#include <osl/thread.hxx>
#include <o3tl/environment.hxx>
#include <o3tl/string_view.hxx>
#include <jvmfwk/framework.hxx>
#include <vendorbase.hxx>
@@ -273,15 +274,12 @@ javaFrameworkError jfw_startVM(
// java.library.path. Somehow setting java.library.path accordingly doesn't work,
// but the PATH gets picked up, so add it there.
// Without this hack, some features don't work in alternative JREs.
OUString sPATH;
osl_getEnvironment(OUString("PATH").pData, &sPATH.pData);
OUString sJRELocation;
osl::FileBase::getSystemPathFromFileURL(pInfo->sLocation + "/bin", sJRELocation);
if (sPATH.isEmpty())
sPATH = sJRELocation;
else
sPATH = sJRELocation + OUStringChar(SAL_PATHSEPARATOR) + sPATH;
osl_setEnvironment(OUString("PATH").pData, sPATH.pData);
OUString sOldPATH = o3tl::getEnvironment(u"PATH"_ustr);
OUString sNewPATH;
osl::FileBase::getSystemPathFromFileURL(pInfo->sLocation + "/bin", sNewPATH);
if (!sOldPATH.isEmpty())
sNewPATH += OUStringChar(SAL_PATHSEPARATOR) + sOldPATH;
o3tl::setEnvironment(u"PATH"_ustr, sNewPATH);
#endif // _WIN32
// create JavaVMOptions array that is passed to the plugin
+7 -8
View File
@@ -24,6 +24,7 @@
#include <o3tl/any.hxx>
#include <o3tl/char16_t2wchar_t.hxx>
#include <o3tl/environment.hxx>
#include <osl/process.h>
#include <osl/file.hxx>
@@ -179,12 +180,12 @@ static void prependPythonPath( std::u16string_view pythonPathBootstrap )
break;
nIndex = nNew + 1;
}
const char * oldEnv = getenv( "PYTHONPATH");
if( oldEnv )
OUString oldEnv = o3tl::getEnvironment(u"PYTHONPATH"_ustr);
if (!oldEnv.isEmpty())
{
if (bAppendSep)
bufPYTHONPATH.append( static_cast<sal_Unicode>(SAL_PATHSEPARATOR) );
bufPYTHONPATH.append( OUString(oldEnv, strlen(oldEnv), osl_getThreadTextEncoding()) );
bufPYTHONPATH.append(oldEnv);
}
OUString envVar(u"PYTHONPATH"_ustr);
@@ -229,14 +230,12 @@ void pythonInit() {
#ifdef _WIN32
//extend PATH under windows to include the branddir/program so ssl libs will be found
//for use by terminal mailmerge dependency _ssl.pyd
OUString sEnvName("PATH");
OUString sPath;
osl_getEnvironment(sEnvName.pData, &sPath.pData);
OUString sPath = o3tl::getEnvironment(u"PATH"_ustr);
OUString sBrandLocation("$BRAND_BASE_DIR/program");
rtl::Bootstrap::expandMacros(sBrandLocation);
osl::FileBase::getSystemPathFromFileURL(sBrandLocation, sBrandLocation);
sPath = sPath + OUStringChar(SAL_PATHSEPARATOR) + sBrandLocation;
osl_setEnvironment(sEnvName.pData, sPath.pData);
sPath += OUStringChar(SAL_PATHSEPARATOR) + sBrandLocation;
o3tl::setEnvironment(u"PATH"_ustr, sPath);
#endif
PyImport_AppendInittab( "pyuno", PyInit_pyuno );
+3 -5
View File
@@ -22,6 +22,7 @@
#include <osl/process.h>
#include <osl/diagnose.hxx>
#include <sal/log.hxx>
#include <o3tl/environment.hxx>
#include <o3tl/string_view.hxx>
#include <algorithm>
@@ -34,12 +35,9 @@ const std::vector<OString>& StaticDebugBaseAddressFilter()
static const std::vector<OString> theFilter = []()
{
std::vector<OString> vec;
rtl_uString * pStr = nullptr;
if (osl_getEnvironment( u"OSL_DEBUGBASE_STORE_ADDRESSES"_ustr.pData, &pStr )
== osl_Process_E_None)
OUString const str(o3tl::getEnvironment(u"OSL_DEBUGBASE_STORE_ADDRESSES"_ustr));
if (!str.isEmpty())
{
OUString const str(pStr);
rtl_uString_release(pStr);
sal_Int32 nIndex = 0;
do {
vec.push_back( OUStringToOString(
+2 -2
View File
@@ -32,6 +32,7 @@
#include <osl/diagnose.h>
#include <osl/file.hxx>
#include <o3tl/char16_t2wchar_t.hxx>
#include <o3tl/environment.hxx>
#include <vector>
#include <algorithm>
@@ -347,8 +348,7 @@ namespace /* private */
OUString get_batch_processor()
{
OUString comspec;
osl_getEnvironment(u"COMSPEC"_ustr.pData, &comspec.pData);
OUString comspec = o3tl::getEnvironment(u"COMSPEC"_ustr);
OSL_ASSERT(comspec.getLength());
+2 -4
View File
@@ -52,6 +52,7 @@
#include <unotools/pathoptions.hxx>
#include <rtl/byteseq.hxx>
#include <rtl/ustring.hxx>
#include <o3tl/environment.hxx>
#include <o3tl/string_view.hxx>
#include <officecfg/Office/Common.hxx>
#include <osl/process.h>
@@ -344,10 +345,7 @@ SfxHelp::SfxHelp()
{
// read the environment variable "HELP_DEBUG"
// if it's set, you will see debug output on active help
OUString sHelpDebug;
OUString sEnvVarName( u"HELP_DEBUG"_ustr );
osl_getEnvironment( sEnvVarName.pData, &sHelpDebug.pData );
bIsDebug = !sHelpDebug.isEmpty();
bIsDebug = !o3tl::getEnvironment(u"HELP_DEBUG"_ustr).isEmpty();
}
SfxHelp::~SfxHelp()
+4 -15
View File
@@ -43,6 +43,7 @@
#include <o3tl/string_view.hxx>
#include <osl/file.hxx>
#include <osl/mutex.hxx>
#include <osl/process.h>
#include <unotools/historyoptions.hxx>
#include <unotools/pathoptions.hxx>
#include <ucbhelper/commandenvironment.hxx>
@@ -653,16 +654,8 @@ void SvtMatchContext_Impl::doExecute()
/** Parse leading ~ for Unix systems,
does nothing for Windows
*/
bool SvtURLBox_Impl::TildeParsing(
OUString&
#ifdef UNX
aText
#endif
, OUString&
#ifdef UNX
aBaseURL
#endif
)
bool SvtURLBox_Impl::TildeParsing([[maybe_unused]] OUString& aText,
[[maybe_unused]] OUString& aBaseURL)
{
#ifdef UNX
if( aText.startsWith( "~" ) )
@@ -673,11 +666,7 @@ bool SvtURLBox_Impl::TildeParsing(
if( aText.getLength() == 1 || aText[ 1 ] == '/' )
{
// covers "~" or "~/..." cases
const char* aHomeLocation = getenv( "HOME" );
if( !aHomeLocation )
aHomeLocation = "";
aParseTilde = OUString::createFromAscii(aHomeLocation);
osl_getEnvironment(u"HOME"_ustr.pData, &aParseTilde.pData);
// in case the whole path is just "~" then there should
// be no trailing slash at the end
@@ -10,6 +10,7 @@
#include <swmodeltestbase.hxx>
#include <config_folders.h>
#include <o3tl/environment.hxx>
#include <osl/process.h>
#include <osl/file.hxx>
@@ -59,8 +60,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf166850_ODT)
// test ODT import from version 24.2 where this worked
// but only in the same locale that was used to import from DOCX, not in
// a different one
OUString instdir;
osl_getEnvironment(u"INSTDIR"_ustr.pData, &instdir.pData);
OUString instdir = o3tl::getEnvironment(u"INSTDIR"_ustr);
OUString url;
CPPUNIT_ASSERT_EQUAL(::osl::FileBase::E_None,
::osl::FileBase::getFileURLFromSystemPath(instdir, url));
+3 -4
View File
@@ -15,6 +15,7 @@
#include <com/sun/star/frame/Desktop.hpp>
#include <comphelper/processfactory.hxx>
#include <o3tl/environment.hxx>
#include <vcl/abstdlg.hxx>
#include <vcl/filter/PngImageWriter.hxx>
#include <vcl/svapp.hxx>
@@ -51,12 +52,10 @@ using namespace css::uno;
constexpr OUString g_aScreenshotDirectory(u"screenshots"_ustr);
ScreenshotTest::ScreenshotTest()
: maParent(nullptr, u"vcl/ui/screenshotparent.ui"_ustr, u"ScreenShot"_ustr)
: maCurrentLanguage(o3tl::getEnvironment(u"LO_TEST_LOCALE"_ustr))
, maParent(nullptr, u"vcl/ui/screenshotparent.ui"_ustr, u"ScreenShot"_ustr)
, mxParentWidget(maParent.getDialog()->weld_content_area())
{
if (auto const env = getenv("LO_TEST_LOCALE")) {
maCurrentLanguage = OUString::fromUtf8(env);
}
}
ScreenshotTest::~ScreenshotTest()
+3 -4
View File
@@ -16,6 +16,7 @@
#include <comphelper/processfactory.hxx>
#include <i18nlangtag/languagetag.hxx>
#include <i18nlangtag/mslangid.hxx>
#include <o3tl/environment.hxx>
#include <unotools/configmgr.hxx>
#include <unotools/syslocaleoptions.hxx>
#include <vcl/svapp.hxx>
@@ -72,10 +73,8 @@ IMPL_STATIC_LINK_NOARG(Hook, deinitHook, LinkParamNone *, void) {
void test::setUpVcl(bool const forceHeadless) {
// Force locale (and resource files loaded):
OUString locale;
if (getenv("LO_TEST_LOCALE") != nullptr)
locale = OUString::fromUtf8(getenv("LO_TEST_LOCALE"));
else
OUString locale = o3tl::getEnvironment(u"LO_TEST_LOCALE"_ustr);
if (locale.isEmpty())
locale = "en-US";
SvtSysLocaleOptions localOptions;
+3 -3
View File
@@ -10,8 +10,8 @@
#include <sal/config.h>
#include <cppunit/TestAssert.h>
#include <o3tl/environment.hxx>
#include <osl/file.hxx>
#include <osl/process.h>
#include <unotest/directories.hxx>
namespace
@@ -30,10 +30,10 @@ OUString getFileURLFromSystemPath(OUString const& path)
}
test::Directories::Directories()
: m_aSrcRootPath(o3tl::getEnvironment(u"SRC_ROOT"_ustr))
, m_aWorkdirRootPath(o3tl::getEnvironment(u"WORKDIR_FOR_BUILD"_ustr))
{
osl_getEnvironment(u"SRC_ROOT"_ustr.pData, &m_aSrcRootPath.pData);
CPPUNIT_ASSERT_MESSAGE("SRC_ROOT env variable not set", !m_aSrcRootPath.isEmpty());
osl_getEnvironment(u"WORKDIR_FOR_BUILD"_ustr.pData, &m_aWorkdirRootPath.pData);
CPPUNIT_ASSERT_MESSAGE("WORKDIR_FOR_BUILD env variable not set", !m_aWorkdirRootPath.isEmpty());
m_aSrcRootURL = getFileURLFromSystemPath(m_aSrcRootPath);
m_aWorkdirRootURL = getFileURLFromSystemPath(m_aWorkdirRootPath);
+2 -2
View File
@@ -25,6 +25,7 @@
#include <comphelper/sequence.hxx>
#include <comphelper/processfactory.hxx>
#include <unotest/directories.hxx>
#include <o3tl/environment.hxx>
#include <osl/file.hxx>
#include <osl/process.h>
#include <osl/thread.h>
@@ -213,8 +214,7 @@ extern "C" {
SAL_DLLPUBLIC_EXPORT
void test_init_gpg(OUString const& rTargetDir)
{
OUString srcRootPath;
osl_getEnvironment(u"SRC_ROOT"_ustr.pData, &srcRootPath.pData);
OUString const srcRootPath = o3tl::getEnvironment(u"SRC_ROOT"_ustr);
if (srcRootPath.isEmpty())
{
abort();
+4 -7
View File
@@ -20,6 +20,7 @@
#include <sal/log.hxx>
#include <rtl/crc.h>
#include <rtl/math.hxx>
#include <o3tl/environment.hxx>
#include <o3tl/underlyingenumvalue.hxx>
#include <osl/diagnose.h>
#include <basegfx/matrix/b2dhommatrixtools.hxx>
@@ -1492,18 +1493,14 @@ void BitmapEx::GetColorModel(css::uno::Sequence< sal_Int32 >& rRGBPalette,
void BitmapEx::DumpAsPng(const char* pFileName) const
{
OUString sPath;
OUString sPath(u"file:///tmp/bitmap.png"_ustr);
if (pFileName)
{
sPath = OUString::fromUtf8(pFileName);
}
else if (const char* pEnv = std::getenv("VCL_DUMP_BMP_PATH"))
else if (OUString env = o3tl::getEnvironment(u"VCL_DUMP_BMP_PATH"_ustr); !env.isEmpty())
{
sPath = OUString::fromUtf8(pEnv);
}
else
{
sPath = "file:///tmp/bitmap.png";
sPath = env;
}
SvFileStream aStream(sPath, StreamMode::STD_READWRITE | StreamMode::TRUNC);
assert(aStream.good());
+2 -1
View File
@@ -52,6 +52,7 @@
#ifdef DBG_UTIL
#include <cstdlib>
#include <o3tl/environment.hxx>
#include <tools/stream.hxx>
#include <vcl/graphicfilter.hxx>
#endif
@@ -149,7 +150,7 @@ Bitmap::~Bitmap()
{
#ifdef DBG_UTIL
// VCL_DUMP_BMP_PATH should be like C:/path/ or ~/path/
static const OUString sDumpPath(OUString::createFromAscii(std::getenv("VCL_DUMP_BMP_PATH")));
static const OUString sDumpPath(o3tl::getEnvironment(u"VCL_DUMP_BMP_PATH"_ustr));
// Stepping into the dtor of a bitmap you need, and setting the volatile variable to true in
// debugger, would dump the bitmap in question
static volatile bool save(false);
@@ -39,6 +39,7 @@
#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
#include <osl/file.hxx>
#include <osl/process.h>
#include <sal/log.hxx>
#include <unotools/datetime.hxx>
@@ -106,10 +107,7 @@ bool GetPathAllOS(OUString& aPath)
return false;
aPath = o3tl::toU(sPath);
#else
const char* cPath = getenv("PATH");
if (!cPath)
return false;
aPath = OUString(cPath, strlen(cPath), osl_getThreadTextEncoding());
osl_getEnvironment(u"PATH"_ustr.pData, &aPath.pData);
#endif
return (!aPath.isEmpty());
}
@@ -28,6 +28,7 @@
#include <sal/types.h>
#include <rtl/bootstrap.hxx>
#include <rtl/string.hxx>
#include <o3tl/environment.hxx>
#include <osl/file.hxx>
#include <osl/process.h>
#include <osl/thread.h>
@@ -177,8 +178,7 @@ const OUString & ONSSInitializer::getMozillaCurrentProfile(const css::uno::Refer
m_bIsNSSinitialized = true;
// first, try to get the profile from "MOZILLA_CERTIFICATE_FOLDER"
if (OUString pEnv; osl_getEnvironment(u"MOZILLA_CERTIFICATE_FOLDER"_ustr.pData, &pEnv.pData) == osl_Process_E_None
&& !pEnv.isEmpty())
if (OUString pEnv = o3tl::getEnvironment(u"MOZILLA_CERTIFICATE_FOLDER"_ustr); !pEnv.isEmpty())
{
SAL_INFO(
"xmlsecurity.xmlsec",
@@ -285,8 +285,7 @@ css::uno::Sequence<css::xml::crypto::NSSProfile> SAL_CALL ONSSInitializer::getNS
}
aProfileList.push_back({u"MANUAL"_ustr, sUserSelect, mozilla::MozillaProductType_Default});
OUString pEnv;
osl_getEnvironment(u"MOZILLA_CERTIFICATE_FOLDER"_ustr.pData, &pEnv.pData);
OUString pEnv = o3tl::getEnvironment(u"MOZILLA_CERTIFICATE_FOLDER"_ustr);
aProfileList.push_back({u"MOZILLA_CERTIFICATE_FOLDER"_ustr,
pEnv,
mozilla::MozillaProductType_Default});