LibreOffice Module comphelper (master)  1
backupfilehelper.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  */
9 
10 #ifndef INCLUDED_COMPHELPER_BACKUPFILEHELPER_HXX
11 #define INCLUDED_COMPHELPER_BACKUPFILEHELPER_HXX
12 
13 #include <sal/config.h>
14 
16 #include <rtl/ustring.hxx>
17 #include <set>
18 #include <vector>
19 
20 namespace comphelper
21 {
59  {
60  private:
61  // internal data
62  std::set< OUString > maDirs;
63  std::set< std::pair< OUString, OUString > > maFiles;
64 
65  sal_uInt16 mnNumBackups;
66  sal_uInt16 mnMode;
67 
68  bool mbActive;
70  bool mbCompress;
71 
72  // internal flag if _exit() was called already - a hint to evtl.
73  // not create copies of potentially not well-defined data. This
74  // may be used in destructors of static instances - which unfortunately
75  // get called on WNT but not on linux. Thus I thought about encapsulating
76  // in some '#ifdefs', but it's just more safe to always do it and
77  // allows to add a SAL_WARN when one of these destructors is called
78  // after _exit()
79  static bool mbExitWasCalled;
80 
81  // internal detector if SafeModeName dir exists
82  static bool mbSafeModeDirExists;
83 
84  // internal upper limit (max) of allowed backups
85  static sal_uInt16 mnMaxAllowedBackups;
86 
87  // path to User's configuration directory and derived strings
88  static OUString maInitialBaseURL;
89  static OUString maUserConfigBaseURL;
90  static OUString maUserConfigWorkURL;
91  static OUString maRegModName;
92  static OUString maExt;
93 
94  // get path to User's configuration directory (created on-demand)
95  static const OUString& getInitialBaseURL();
96 
97  // the name of the SafeMode directory for temporary processing
98  static const OUString& getSafeModeName();
99 
100  public:
106 
107  // allow to set static global flag when app had to call _exit()
108  static void setExitWasCalled();
109  static bool getExitWasCalled();
110 
111  // This call initializes the state of the UserDirectory as needed, it may
112  // initialize to SafeMode configuration or return from it by moving files
113  // in that directory
114  static void reactOnSafeMode(bool bSafeMode);
115 
124  void tryPush();
125  void tryPushExtensionInfo();
126 
134  bool isPopPossible();
135  bool isPopPossibleExtensionInfo() const;
136 
144  void tryPop();
145  void tryPopExtensionInfo();
146 
149  static bool isTryDisableAllExtensionsPossible();
150  static void tryDisableAllExtensions();
151 
154  static bool isTryDeinstallUserExtensionsPossible();
155  static void tryDeinstallUserExtensions();
156 
159  static bool isTryResetSharedExtensionsPossible();
160  static void tryResetSharedExtensions();
161 
164  static bool isTryResetBundledExtensionsPossible();
165  static void tryResetBundledExtensions();
166 
168  static void tryDisableHWAcceleration();
169 
172  static bool isTryResetCustomizationsPossible();
173  static void tryResetCustomizations();
174 
177  static void tryResetUserProfile();
178 
180  static const OUString& getUserProfileURL();
181 
183  static const OUString& getUserProfileWorkURL();
184 
185  private:
186  // internal helper methods
187  static OUString getPackURL();
188  static const std::vector< OUString >& getCustomizationDirNames();
189  static const std::vector< OUString >& getCustomizationFileNames();
190 
191  // file push helpers
192  bool tryPush_Files(const std::set< OUString >& rDirs, const std::set< std::pair< OUString, OUString > >& rFiles, const OUString& rSourceURL, const OUString& rTargetURL);
193  bool tryPush_file(const OUString& rSourceURL, const OUString& rTargetURL, const OUString& rName, const OUString& rExt);
194 
195  // file pop possibilities helper
196  bool isPopPossible_files(const std::set< OUString >& rDirs, const std::set< std::pair< OUString, OUString > >& rFiles, const OUString& rSourceURL, const OUString& rTargetURL);
197  static bool isPopPossible_file(const OUString& rSourceURL, const OUString& rTargetURL, const OUString& rName, const OUString& rExt);
198 
199  // file pop helpers
200  bool tryPop_files(const std::set< OUString >& rDirs, const std::set< std::pair< OUString, OUString > >& rFiles, const OUString& rSourceURL, const OUString& rTargetURL);
201  bool tryPop_file(const OUString& rSourceURL, const OUString& rTargetURL, const OUString& rName, const OUString& rExt);
202 
203  // ExtensionInfo helpers
204  bool tryPush_extensionInfo(const OUString& rTargetURL);
205  static bool isPopPossible_extensionInfo(const OUString& rTargetURL);
206  bool tryPop_extensionInfo(const OUString& rTargetURL);
207 
208  // FileDirInfo helpers
209  void fillDirFileInfo();
210  };
211 }
212 
213 #endif
214 
215 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::set< std::pair< OUString, OUString > > maFiles
Helper class to backup/restore a single file.
static sal_uInt16 mnMaxAllowedBackups
#define COMPHELPER_DLLPUBLIC