Mercurial > hg > forks > UniversalIndentGUI
annotate src/SettingsPaths.cpp @ 716:b9123ff53106
Run cppcheck over the code and removed some possible problems.
git-svn-id: svn://svn.code.sf.net/p/universalindent/code/trunk@987 59b1889a-e5ac-428c-b0c7-476e01d41282
author | thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282> |
---|---|
date | Fri, 21 Aug 2009 09:38:00 +0000 |
parents | 3363b7bb0d41 |
children | aae5a8d04f70 |
rev | line source |
---|---|
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
1 /*************************************************************************** |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
2 * Copyright (C) 2006-2009 by Thomas Schweitzer * |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
3 * thomas-schweitzer(at)arcor.de * |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
4 * * |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
5 * This program is free software; you can redistribute it and/or modify * |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
6 * it under the terms of the GNU General Public License version 2.0 as * |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
7 * published by the Free Software Foundation. * |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
8 * * |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
9 * This program is distributed in the hope that it will be useful, * |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
12 * GNU General Public License for more details. * |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
13 * * |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
14 * You should have received a copy of the GNU General Public License * |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
15 * along with this program in the file LICENSE.GPL; if not, write to the * |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
16 * Free Software Foundation, Inc., * |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
17 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
18 ***************************************************************************/ |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
19 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
20 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
21 #include <stdlib.h> |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
22 #include <QDirIterator> |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
23 #include <QStack> |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
24 #include <QtDebug> |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
25 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
26 #include "SettingsPaths.h" |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
27 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
28 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
29 //! \defgroup grp_Settings All concerning applications settings. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
30 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
31 /*! |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
32 \class SettingsPaths |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
33 \ingroup grp_Settings |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
34 \brief SettingsPaths is a pure static functions class from which info about the |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
35 paths needed for settings can be retrieved. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
36 */ |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
37 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
38 bool SettingsPaths::alreadyInitialized = false; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
39 QString SettingsPaths::applicationBinaryPath = ""; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
40 QString SettingsPaths::settingsPath = ""; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
41 QString SettingsPaths::globalFilesPath = ""; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
42 QString SettingsPaths::indenterPath = ""; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
43 QString SettingsPaths::tempPath = ""; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
44 bool SettingsPaths::portableMode = false; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
45 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
46 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
47 /*! |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
48 \brief Initializes all available information about the paths. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
49 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
50 Mainly during this init it is detected whether to start in portable mode or not. This is |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
51 done by testing whether the directory "config" is in the same directory as this |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
52 applications executable file. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
53 In portable mode all data is ONLY written to subdirectories of the applications executable file. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
54 Means also that the directory "indenters" has to be there. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
55 In not portable mode (multiuser mode) only users home directory is used for writing config data. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
56 */ |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
57 void SettingsPaths::init() { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
58 alreadyInitialized = true; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
59 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
60 qDebug() << __LINE__ << " " << __FUNCTION__ << ": Initializing application paths."; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
61 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
62 // Get the applications binary path, with respect to MacOSXs use of the .app folder. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
63 applicationBinaryPath = QCoreApplication::applicationDirPath(); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
64 // Remove any trailing slashes |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
65 while ( applicationBinaryPath.right(1) == "/" ) { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
66 applicationBinaryPath.chop(1); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
67 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
68 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
69 #ifdef UNIVERSALINDENTGUI_NPP_EXPORTS |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
70 applicationBinaryPath += "/plugins/uigui"; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
71 #endif |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
72 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
73 #ifdef Q_OS_MAC |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
74 // Because on Mac universal binaries are used, the binary path is not equal |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
75 // to the applications (.app) path. So get the .apps path here. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
76 int indexOfDotApp = applicationBinaryPath.indexOf(".app"); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
77 if ( indexOfDotApp != -1 ) { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
78 // Cut off after the dot of ".app". |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
79 applicationBinaryPath = applicationBinaryPath.left( indexOfDotApp-1 ); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
80 // Cut off after the first slash that was in front of ".app" (normally this is the word "UniversalIndentGUI") |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
81 applicationBinaryPath = applicationBinaryPath.left( applicationBinaryPath.lastIndexOf("/") ); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
82 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
83 #endif |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
84 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
85 // If the "config" directory is a subdir of the applications binary path, use this one (portable mode) |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
86 settingsPath = applicationBinaryPath + "/config"; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
87 if ( QFile::exists( settingsPath ) ) { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
88 portableMode = true; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
89 QDir dirCreator; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
90 globalFilesPath = applicationBinaryPath; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
91 indenterPath = applicationBinaryPath + "/indenters"; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
92 dirCreator.mkpath( settingsPath ); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
93 tempPath = applicationBinaryPath + "/temp"; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
94 //TODO: If the portable drive has write protection, use local temp path and clean it up on exit. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
95 dirCreator.mkpath( tempPath ); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
96 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
97 // ... otherwise use the system specific global application data path. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
98 else { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
99 portableMode = false; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
100 QDir dirCreator; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
101 #ifdef Q_OS_WIN |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
102 // Get the local users application settings directory. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
103 // Remove any trailing slashes. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
104 settingsPath = QDir::fromNativeSeparators( qgetenv("APPDATA") ); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
105 while ( settingsPath.right(1) == "/" ) { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
106 settingsPath.chop(1); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
107 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
108 settingsPath = settingsPath + "/UniversalIndentGUI"; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
109 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
110 // On windows systems the directories "indenters", "translations" are subdirs of the applicationBinaryPath. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
111 globalFilesPath = applicationBinaryPath; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
112 #else |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
113 // Remove any trailing slashes. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
114 settingsPath = QDir::homePath(); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
115 while ( settingsPath.right(1) == "/" ) { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
116 settingsPath.chop(1); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
117 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
118 settingsPath = settingsPath + "/.universalindentgui"; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
119 globalFilesPath = "/usr/share/universalindentgui"; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
120 #endif |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
121 dirCreator.mkpath( settingsPath ); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
122 // If a highlighter config file does not exist in the users home config dir |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
123 // copy the default config file over there. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
124 if ( !QFile::exists(settingsPath+"/UiGuiSyntaxHighlightConfig.ini") ) { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
125 QFile::copy( globalFilesPath+"/config/UiGuiSyntaxHighlightConfig.ini", settingsPath+"/UiGuiSyntaxHighlightConfig.ini" ); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
126 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
127 indenterPath = globalFilesPath + "/indenters"; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
128 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
129 // On different systems it may be that "QDir::tempPath()" ends with a "/" or not. So check this. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
130 // Remove any trailing slashes. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
131 tempPath = QDir::tempPath(); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
132 while ( tempPath.right(1) == "/" ) { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
133 tempPath.chop(1); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
134 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
135 tempPath = tempPath + "/UniversalIndentGUI"; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
136 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
137 #if defined(Q_OS_WIN32) |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
138 dirCreator.mkpath( tempPath ); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
139 #else |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
140 // On Unix based systems create a random temporary directory for security |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
141 // reasons. Otherwise an evil human being could create a symbolic link |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
142 // to an important existing file which gets overwritten when UiGUI writes |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
143 // into this normally temporary but linked file. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
144 char *pathTemplate = new char[tempPath.length()+8]; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
145 QByteArray pathTemplateQBA = QString(tempPath + "-XXXXXX").toAscii(); |
716
b9123ff53106
Run cppcheck over the code and removed some possible problems.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
714
diff
changeset
|
146 delete [] pathTemplate; |
714
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
147 pathTemplate = pathTemplateQBA.data(); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
148 pathTemplate = mkdtemp( pathTemplate ); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
149 tempPath = pathTemplate; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
150 #endif |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
151 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
152 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
153 qDebug() << __LINE__ << " " << __FUNCTION__ << ": Paths are:" \ |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
154 "<ul><li>applicationBinaryPath=" << applicationBinaryPath \ |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
155 << "</li><li>settingsPath=" << settingsPath \ |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
156 << "</li><li>globalFilesPath=" << globalFilesPath \ |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
157 << "</li><li>indenterPath=" << indenterPath \ |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
158 << "</li><li>tempPath=" << tempPath \ |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
159 << "</li><li>Running in portable mode=" << portableMode << "</li></ul>"; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
160 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
161 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
162 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
163 /*! |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
164 \brief Returns the path of the applications executable. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
165 */ |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
166 const QString SettingsPaths::getApplicationBinaryPath() { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
167 if ( !alreadyInitialized ) { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
168 SettingsPaths::init(); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
169 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
170 return applicationBinaryPath; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
171 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
172 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
173 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
174 /*! |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
175 \brief Returns the path where all settings are being/should be written to. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
176 */ |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
177 const QString SettingsPaths::getSettingsPath() { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
178 if ( !alreadyInitialized ) { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
179 SettingsPaths::init(); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
180 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
181 return settingsPath; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
182 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
183 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
184 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
185 /*! |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
186 \brief Returns the path where the files concerning all users reside. For example translations. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
187 */ |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
188 const QString SettingsPaths::getGlobalFilesPath() { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
189 if ( !alreadyInitialized ) { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
190 SettingsPaths::init(); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
191 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
192 return globalFilesPath; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
193 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
194 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
195 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
196 /*! |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
197 \brief Returns the path where the indenter executables reside. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
198 */ |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
199 const QString SettingsPaths::getIndenterPath() { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
200 if ( !alreadyInitialized ) { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
201 SettingsPaths::init(); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
202 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
203 return indenterPath; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
204 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
205 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
206 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
207 /*! |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
208 \brief Returns the path where the where all temporary data should be written to. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
209 */ |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
210 const QString SettingsPaths::getTempPath() { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
211 if ( !alreadyInitialized ) { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
212 SettingsPaths::init(); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
213 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
214 return tempPath; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
215 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
216 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
217 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
218 /*! |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
219 \brief Returns true if portable mode shall be used. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
220 */ |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
221 bool SettingsPaths::getPortableMode() { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
222 if ( !alreadyInitialized ) { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
223 SettingsPaths::init(); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
224 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
225 return portableMode; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
226 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
227 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
228 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
229 /*! |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
230 \brief Completely deletes the created temporary directory with all of its content. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
231 */ |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
232 void SettingsPaths::cleanAndRemoveTempDir() { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
233 QDirIterator dirIterator(tempPath, QDirIterator::Subdirectories); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
234 QStack<QString> directoryStack; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
235 bool noErrorsOccurred = true; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
236 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
237 while ( dirIterator.hasNext() ) { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
238 QString currentDirOrFile = dirIterator.next(); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
239 // If this dummy call isn't done here, calling "dirIterator.fileInfo().isDir()" later somehow fails. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
240 dirIterator.fileInfo(); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
241 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
242 if ( !currentDirOrFile.isEmpty() && dirIterator.fileName() != "." && dirIterator.fileName() != ".." ) { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
243 // There is a path on the stack but the current path doesn't start with that path. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
244 // So we changed into another parent directory and the one on the stack can be deleted |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
245 // since it must be empty. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
246 if ( !directoryStack.isEmpty() && !currentDirOrFile.startsWith(directoryStack.top()) ) { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
247 QString dirToBeRemoved = directoryStack.pop(); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
248 bool couldRemoveDir = QDir(dirToBeRemoved).rmdir(dirToBeRemoved); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
249 noErrorsOccurred &= couldRemoveDir; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
250 if ( couldRemoveDir == false ) |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
251 qWarning() << __LINE__ << " " << __FUNCTION__ << "Could not remove the directory: " << dirToBeRemoved; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
252 //qDebug() << "Removing Dir " << directoryStack.pop(); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
253 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
254 |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
255 // If the iterator currently points to a directory push it onto the stack. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
256 if ( dirIterator.fileInfo().isDir() ) { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
257 directoryStack.push( currentDirOrFile ); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
258 //qDebug() << "Pushing onto Stack " << currentDirOrFile; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
259 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
260 // otherwise it must be a file, so delete it. |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
261 else { |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
262 bool couldRemoveFile = QFile::remove( currentDirOrFile ); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
263 noErrorsOccurred &= couldRemoveFile; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
264 if ( couldRemoveFile == false ) |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
265 qWarning() << __LINE__ << " " << __FUNCTION__ << "Could not remove the file: " << currentDirOrFile; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
266 //qDebug() << "Removing File " << currentDirOrFile; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
267 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
268 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
269 } |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
270 noErrorsOccurred &= QDir(tempPath).rmdir(tempPath); |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
271 if ( noErrorsOccurred == false ) |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
272 qWarning() << __LINE__ << " " << __FUNCTION__ << "While cleaning up the temp dir an error occurred."; |
3363b7bb0d41
Once more let Uncrustify reformat my code.
thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
parents:
699
diff
changeset
|
273 } |