summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorChris Sherlock <chris.sherlock79@gmail.com>2017-04-30 01:33:36 +1000
committerChris Sherlock <chris.sherlock79@gmail.com>2017-04-29 18:38:09 +0200
commitad3e1afe5969d6c53b1ed285b7c36685bd457b1c (patch)
tree3a474dabeaeb593ce876073b2fe93df940697a6f /unotools
parentd1ac762cd6c60d5fe8ffaf335c6358651c969567 (diff)
Move getProcessWorkingDir from tools to unotools
Change-Id: Ifd86ab3c89c285ad5329fc86cc57967ebd1af91a Reviewed-on: https://gerrit.libreoffice.org/37100 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Chris Sherlock <chris.sherlock79@gmail.com>
Diffstat (limited to 'unotools')
-rw-r--r--unotools/source/config/bootstrap.cxx31
1 files changed, 29 insertions, 2 deletions
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 <config_folders.h>
+#include <cstddef>
#include <stdio.h>
#include <unotools/bootstrap.hxx>
@@ -33,7 +34,9 @@
#include <rtl/bootstrap.hxx>
#include <rtl/instance.hxx>
#include <osl/process.h>
-#include <tools/getprocessworkingdir.hxx>
+
+#include <osl/diagnose.h>
+#include <osl/file.hxx>
// #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))