Use osl_getEnvironment to simplify Directories initialization

Change-Id: Ie2bc87fac14ee60972c1f8ffc70bfa3c45f11de7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187940
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski
2025-07-16 09:43:17 +02:00
parent 0adfac0338
commit a5ea37cbc5
+5 -9
View File
@@ -11,6 +11,7 @@
#include <cppunit/TestAssert.h>
#include <osl/file.hxx>
#include <osl/process.h>
#include <unotest/directories.hxx>
namespace
@@ -30,16 +31,11 @@ OUString getFileURLFromSystemPath(OUString const& path)
test::Directories::Directories()
{
const char* pSrcRoot = getenv("SRC_ROOT");
CPPUNIT_ASSERT_MESSAGE("SRC_ROOT env variable not set", pSrcRoot != nullptr);
CPPUNIT_ASSERT_MESSAGE("SRC_ROOT env variable not set", pSrcRoot[0] != 0);
const char* pWorkdirRoot = getenv("WORKDIR_FOR_BUILD");
CPPUNIT_ASSERT_MESSAGE("$WORKDIR_FOR_BUILD env variable not set", pWorkdirRoot != nullptr);
CPPUNIT_ASSERT_MESSAGE("$WORKDIR_FOR_BUILD env variable not set", pWorkdirRoot[0] != 0);
m_aSrcRootPath = OUString::createFromAscii(pSrcRoot);
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_aWorkdirRootPath = OUString::createFromAscii(pWorkdirRoot);
m_aWorkdirRootURL = getFileURLFromSystemPath(m_aWorkdirRootPath);
}