24#include <com/sun/star/uno/Exception.hpp>
26#include <config_folders.h>
27#include <officecfg/Setup.hxx>
29#include <osl/file.hxx>
30#if defined ANDROID || defined IOS || defined EMSCRIPTEN
31#include <rtl/bootstrap.hxx>
33#include <rtl/ustring.hxx>
43#if !(defined ANDROID || defined IOS || defined EMSCRIPTEN)
44osl::FileBase::RC copyRecursive(
45 OUString
const & srcUri, OUString
const & dstUri)
47 osl::DirectoryItem item;
48 osl::FileBase::RC e = osl::DirectoryItem::get(srcUri, item);
49 if (e != osl::FileBase::E_None) {
52 osl::FileStatus stat1(osl_FileStatus_Mask_Type);
53 e = item.getFileStatus(stat1);
54 if (e != osl::FileBase::E_None) {
57 if (stat1.getFileType() == osl::FileStatus::Directory) {
59 if (e != osl::FileBase::E_None && e != osl::FileBase::E_EXIST) {
62 osl::Directory dir(srcUri);
64 if (e != osl::FileBase::E_None) {
68 e = dir.getNextItem(item);
69 if (e == osl::FileBase::E_NOENT) {
72 if (e != osl::FileBase::E_None) {
75 osl::FileStatus stat2(
76 osl_FileStatus_Mask_FileName | osl_FileStatus_Mask_FileURL);
77 e = item.getFileStatus(stat2);
78 if (e != osl::FileBase::E_None) {
81 assert(!dstUri.endsWith(
"/"));
83 stat2.getFileURL(), dstUri +
"/" + stat2.getFileName());
86 if (e != osl::FileBase::E_None) {
92 e = osl::File::copy(srcUri, dstUri);
93 if (e == osl::FileBase::E_EXIST) {
95 e = osl::FileBase::E_None;
103 osl::FileBase::RC e = osl::Directory::createPath(uri);
104 if (e != osl::FileBase::E_None && e != osl::FileBase::E_EXIST) {
107#if !(defined ANDROID || defined IOS || defined EMSCRIPTEN)
110 osl::File::setAttributes(
112 (osl_File_Attribute_OwnWrite | osl_File_Attribute_OwnRead
113 | osl_File_Attribute_OwnExe));
122 switch (copyRecursive(
123 baseUri +
"/" LIBO_SHARE_PRESETS_FOLDER, uri +
"/user"))
125 case osl::FileBase::E_None:
127 case osl::FileBase::E_ACCES:
129 case osl::FileBase::E_NOSPC:
137 OUString userDir(
"${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER
"/" SAL_CONFIGFILE(
"bootstrap")
":UserInstallation}/user");
138 rtl::Bootstrap::expandMacros(userDir);
139 osl::Directory::createPath(userDir);
141 std::shared_ptr<comphelper::ConfigurationChanges> batch(
143 officecfg::Setup::Office::ooSetupInstCompleted::set(
true, batch);
150 return officecfg::Setup::Office::ooSetupInstCompleted::get();
151 }
catch (
const css::uno::Exception &) {
static std::shared_ptr< ConfigurationChanges > create()
static PathStatus locateUserInstallation(OUString &_rURL)
static PathStatus locateBaseInstallation(OUString &_rURL)
#define SAL_CONFIGFILE(name)
#define TOOLS_WARN_EXCEPTION(area, stream)
css::uno::Reference< css::deployment::XPackageRegistry > create(css::uno::Reference< css::deployment::XPackageRegistry > const &xRootRegistry, OUString const &context, OUString const &cachePath, css::uno::Reference< css::uno::XComponentContext > const &xComponentContext)