Kaydet (Commit) ad3e1afe authored tarafından Chris Sherlock's avatar Chris Sherlock

Move getProcessWorkingDir from tools to unotools

Change-Id: Ifd86ab3c89c285ad5329fc86cc57967ebd1af91a
Reviewed-on: https://gerrit.libreoffice.org/37100Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarChris Sherlock <chris.sherlock79@gmail.com>
üst d1ac762c
......@@ -33,7 +33,7 @@
#include <comphelper/lok.hxx>
#include <comphelper/processfactory.hxx>
#include <com/sun/star/uri/ExternalUriReferenceTranslator.hpp>
#include <tools/getprocessworkingdir.hxx>
#include <unotools/bootstrap.hxx>
#include <svl/documentlockfile.hxx>
......@@ -79,7 +79,7 @@ public:
m_index(0)
{
OUString url;
if (tools::getProcessWorkingDir(url)) {
if (utl::Bootstrap::getProcessWorkingDir(url)) {
m_cwdUrl.reset(url);
}
}
......
......@@ -45,7 +45,6 @@
#include <cppuhelper/supportsservice.hxx>
#include <osl/file.hxx>
#include <rtl/process.h>
#include <tools/getprocessworkingdir.hxx>
#include <algorithm>
#include <cassert>
......@@ -494,7 +493,7 @@ RequestHandler::Status DbusIpcThread::enable(rtl::Reference<IpcThread> * thread)
{
OStringBuffer buf(ARGUMENT_PREFIX);
OUString arg;
if (!(tools::getProcessWorkingDir(arg)
if (!(utl::Bootstrap::getProcessWorkingDir(arg)
&& addArgument(buf, '1', arg)))
{
buf.append('0');
......@@ -875,7 +874,7 @@ RequestHandler::Status PipeIpcThread::enable(rtl::Reference<IpcThread> * thread)
OStringBuffer aArguments(ARGUMENT_PREFIX);
OUString cwdUrl;
if (!(tools::getProcessWorkingDir(cwdUrl) &&
if (!(utl::Bootstrap::getProcessWorkingDir(cwdUrl) &&
addArgument(aArguments, '1', cwdUrl)))
{
aArguments.append('0');
......@@ -1309,7 +1308,7 @@ static void AddConversionsToDispatchList(
}
else
{
::tools::getProcessWorkingDir( aPWD );
utl::Bootstrap::getProcessWorkingDir( aPWD );
}
if( !::osl::FileBase::getAbsoluteFileURL( aPWD, rParamOut, aOutDir ) )
......
......@@ -19,11 +19,8 @@
#include <config_folders.h>
#include "deployment.hrc"
#include "unopkg_shared.h"
#include "dp_identifier.hxx"
#include "dp_gui.hrc"
#include "lockfile.hxx"
#include <stdio.h>
#include <vcl/svapp.hxx>
#include <vcl/msgbox.hxx>
#include <rtl/bootstrap.hxx>
......@@ -32,14 +29,20 @@
#include <osl/process.h>
#include <osl/file.hxx>
#include <osl/thread.hxx>
#include <tools/getprocessworkingdir.hxx>
#include <comphelper/processfactory.hxx>
#include <unotools/configmgr.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/ucb/UniversalContentBroker.hpp>
#include <unotools/bootstrap.hxx>
#include <cppuhelper/bootstrap.hxx>
#include <comphelper/sequence.hxx>
#include <stdio.h>
#include <comphelper/processfactory.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/ucb/UniversalContentBroker.hpp>
#include "deployment.hrc"
#include "unopkg_shared.h"
#include "dp_identifier.hxx"
#include "dp_gui.hrc"
#include "lockfile.hxx"
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
......@@ -169,7 +172,7 @@ struct ProcessWorkingDir : public rtl::StaticWithInit<
OUString, ProcessWorkingDir> {
const OUString operator () () {
OUString workingDir;
tools::getProcessWorkingDir(workingDir);
utl::Bootstrap::getProcessWorkingDir(workingDir);
return workingDir;
}
};
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_TOOLS_GETPROCESSWORKINGDIR_HXX
#define INCLUDED_TOOLS_GETPROCESSWORKINGDIR_HXX
#include <rtl/ustring.hxx>
#include <tools/toolsdllapi.h>
namespace tools {
// get the process's current working directory, taking OOO_CWD into account
//
// @param rUrl
// Receives the directory URL (with or without a final slash) upon successful
// return, and the empty string upon unsuccessful return
TOOLS_DLLPUBLIC bool getProcessWorkingDir(OUString& rUrl);
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -107,6 +107,10 @@ namespace utl
*/
static Status checkBootstrapStatus(OUString& _rDiagnosticMessage, FailureCode& _rErrCode);
public:
/// get the working directory of the process
static bool getProcessWorkingDir(OUString &rUrl);
public:
// singleton impl-class
class Impl;
......
......@@ -26,9 +26,9 @@
#include <osl/process.h>
#include <tools/debug.hxx>
#include <tools/urlobj.hxx>
#include <tools/getprocessworkingdir.hxx>
#include <i18nlangtag/languagetag.hxx>
#include <i18nlangtag/mslangid.hxx>
#include <unotools/bootstrap.hxx>
#include <unotools/lingucfg.hxx>
#include <unotools/pathoptions.hxx>
#include <rtl/ustring.hxx>
......@@ -200,7 +200,7 @@ std::vector< SvtLinguConfigDictionaryEntry > GetOldStyleDics( const char *pDicTy
OUString aRelative;
OUString aAbsolute;
if (!tools::getProcessWorkingDir(aCWD))
if (!utl::Bootstrap::getProcessWorkingDir(aCWD))
continue;
if (osl::FileBase::getFileURLFromSystemPath(aSystem, aRelative)
!= osl::FileBase::E_None)
......
......@@ -69,7 +69,6 @@ $(eval $(call gb_Library_add_exception_objects,tl,\
tools/source/memtools/unqidx \
tools/source/misc/cpuid \
tools/source/misc/extendapplicationenvironment \
tools/source/misc/getprocessworkingdir \
tools/source/rc/rc \
tools/source/rc/resary \
tools/source/rc/resmgr \
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/config.h>
#include <cstddef>
#include <osl/diagnose.h>
#include <osl/file.hxx>
#include <osl/process.h>
#include <rtl/bootstrap.hxx>
#include <rtl/ustring.h>
#include <rtl/ustring.hxx>
#include <tools/getprocessworkingdir.hxx>
namespace tools {
bool 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;
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -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))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment