From ad3e1afe5969d6c53b1ed285b7c36685bd457b1c Mon Sep 17 00:00:00 2001 From: Chris Sherlock Date: Sun, 30 Apr 2017 01:33:36 +1000 Subject: Move getProcessWorkingDir from tools to unotools Change-Id: Ifd86ab3c89c285ad5329fc86cc57967ebd1af91a Reviewed-on: https://gerrit.libreoffice.org/37100 Tested-by: Jenkins Reviewed-by: Chris Sherlock --- unotools/source/config/bootstrap.cxx | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'unotools') diff --git a/unotools/source/config/bootstrap.cxx b/unotools/source/config/bootstrap.cxx index f423909f64ff..50bfa18fb5ae 100644 --- a/unotools/source/config/bootstrap.cxx +++ b/unotools/source/config/bootstrap.cxx @@ -19,6 +19,7 @@ #include +#include #include #include @@ -33,7 +34,9 @@ #include #include #include -#include + +#include +#include // #define this to true, if remembering defaults is not supported properly #define RTL_BOOTSTRAP_DEFAULTS_BROKEN true @@ -123,6 +126,30 @@ const Bootstrap::Impl& Bootstrap::data() return theImpl::get(); } +bool Bootstrap::getProcessWorkingDir(OUString &rUrl) +{ + rUrl.clear(); + OUString s("$OOO_CWD"); + rtl::Bootstrap::expandMacros(s); + if (s.isEmpty()) + { + if (osl_getProcessWorkingDir(&rUrl.pData) == osl_Process_E_None) + return true; + } + else if (s[0] == '1') + { + rUrl = s.copy(1); + return true; + } + else if (s[0] == '2' && + (osl::FileBase::getFileURLFromSystemPath(s.copy(1), rUrl) == + osl::FileBase::E_None)) + { + return true; + } + return false; +} + void Bootstrap::reloadData() { theImpl::get().initialize(); @@ -209,7 +236,7 @@ static bool implEnsureAbsolute(OUString & _rsURL) // also strips embedded dots ! using osl::File; OUString sBasePath; - OSL_VERIFY(tools::getProcessWorkingDir(sBasePath)); + OSL_VERIFY(Bootstrap::getProcessWorkingDir(sBasePath)); OUString sAbsolute; if ( File::E_None == File::getAbsoluteFileURL(sBasePath, _rsURL, sAbsolute)) -- cgit