1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <sfx2/safemode.hxx>
12 #include <config_folders.h>
14 #include <osl/file.hxx>
15 #include <rtl/bootstrap.hxx>
21 bool SafeMode::putFlag()
23 File
safeModeFile(getFilePath("safemode"));
24 if (safeModeFile
.open(osl_File_OpenFlag_Create
) == FileBase::E_None
)
31 bool SafeMode::hasFlag()
33 File
safeModeFile(getFilePath("safemode"));
34 if (safeModeFile
.open(osl_File_OpenFlag_Read
) == FileBase::E_None
)
41 bool SafeMode::removeFlag() { return File::remove(getFilePath("safemode")) == FileBase::E_None
; }
43 bool SafeMode::putRestartFlag()
45 File
restartFile(getFilePath("safemode_restart"));
46 if (restartFile
.open(osl_File_OpenFlag_Create
) == FileBase::E_None
)
53 bool SafeMode::hasRestartFlag()
55 File
restartFile(getFilePath("safemode_restart"));
56 if (restartFile
.open(osl_File_OpenFlag_Read
) == FileBase::E_None
)
63 bool SafeMode::removeRestartFlag()
65 return File::remove(getFilePath("safemode_restart")) == FileBase::E_None
;
68 OUString
SafeMode::getFilePath(const OUString
& sFilename
)
70 OUString
url("${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER
71 "/" SAL_CONFIGFILE("bootstrap") ":UserInstallation}/");
72 rtl::Bootstrap::expandMacros(url
);
74 OUString aProfilePath
;
75 FileBase::getSystemPathFromFileURL(url
, aProfilePath
);
76 (void)FileBase::getAbsoluteFileURL(url
, sFilename
, aProfilePath
);
81 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */