[Libreoffice-commits] core.git: vcl/unx
Mike Kaganski (via logerrit)
logerrit at kemper.freedesktop.org
Mon Jan 13 02:38:52 UTC 2020
vcl/unx/generic/fontmanager/helper.cxx | 53 +++++++++++++++------------------
1 file changed, 25 insertions(+), 28 deletions(-)
New commits:
commit 628189b73465b811fd7083e1fdc8533443b52588
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Mon Jan 13 02:11:38 2020 +0100
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Mon Jan 13 03:38:20 2020 +0100
Use static initializer
Change-Id: If46a12403bf941ed8b4b131bfdfa17667d3f1f0d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86650
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
diff --git a/vcl/unx/generic/fontmanager/helper.cxx b/vcl/unx/generic/fontmanager/helper.cxx
index 9c1649d547f3..c586dcce7d7f 100644
--- a/vcl/unx/generic/fontmanager/helper.cxx
+++ b/vcl/unx/generic/fontmanager/helper.cxx
@@ -21,6 +21,7 @@
#include <sys/stat.h>
#include <limits.h>
+#include <osl/file.hxx>
#include <osl/process.h>
#include <osl/thread.h>
#include <rtl/bootstrap.hxx>
@@ -29,51 +30,47 @@
#include <tools/urlobj.hxx>
#include <unx/helper.hxx>
+#include <tuple>
+
using ::rtl::Bootstrap;
namespace psp {
OUString getOfficePath( whichOfficePath ePath )
{
- static OUString aInstallationRootPath;
- static OUString aUserPath;
- static OUString aConfigPath;
- static bool bOnce = false;
-
- if( ! bOnce )
- {
- bOnce = true;
- OUString aIni;
- Bootstrap::get( "BRAND_BASE_DIR", aInstallationRootPath );
- aIni = aInstallationRootPath + "/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE( "bootstrap" );
- Bootstrap aBootstrap( aIni );
- aBootstrap.getFrom( "CustomDataUrl", aConfigPath );
- aBootstrap.getFrom( "UserInstallation", aUserPath );
- OUString aUPath = aUserPath;
-
- if( aConfigPath.startsWith( "file://" ) )
+ static const auto aPaths = [] {
+ OUString sRoot, sUser, sConfig;
+ Bootstrap::get("BRAND_BASE_DIR", sRoot);
+ Bootstrap aBootstrap(sRoot + "/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("bootstrap"));
+ aBootstrap.getFrom("UserInstallation", sUser);
+ aBootstrap.getFrom("CustomDataUrl", sConfig);
+ OUString aUPath = sUser + "/user/psprint";
+ if (sRoot.startsWith("file://"))
{
OUString aSysPath;
- if( osl_getSystemPathFromFileURL( aConfigPath.pData, &aSysPath.pData ) == osl_File_E_None )
- aConfigPath = aSysPath;
+ if (osl::FileBase::getSystemPathFromFileURL(sRoot, aSysPath) == osl::FileBase::E_None)
+ sRoot = aSysPath;
}
- if( aInstallationRootPath.startsWith( "file://" ) )
+ if (sUser.startsWith("file://"))
{
OUString aSysPath;
- if( osl_getSystemPathFromFileURL( aInstallationRootPath.pData, &aSysPath.pData ) == osl_File_E_None )
- aInstallationRootPath = aSysPath;
+ if (osl::FileBase::getSystemPathFromFileURL(sUser, aSysPath) == osl::FileBase::E_None)
+ sUser = aSysPath;
}
- if( aUserPath.startsWith( "file://" ) )
+ if (sConfig.startsWith("file://"))
{
OUString aSysPath;
- if( osl_getSystemPathFromFileURL( aUserPath.pData, &aSysPath.pData ) == osl_File_E_None )
- aUserPath = aSysPath;
+ if (osl::FileBase::getSystemPathFromFileURL(sConfig, aSysPath) == osl::FileBase::E_None)
+ sConfig = aSysPath;
}
+
// ensure user path exists
- aUPath += "/user/psprint";
SAL_INFO("vcl.fonts", "Trying to create: " << aUPath);
- osl_createDirectoryPath( aUPath.pData, nullptr, nullptr );
- }
+ osl::Directory::createPath(aUPath);
+
+ return std::make_tuple(sRoot, sUser, sConfig);
+ }();
+ const auto& [aInstallationRootPath, aUserPath, aConfigPath] = aPaths;
switch( ePath )
{
More information about the Libreoffice-commits
mailing list