diff --git a/docs/d2/dad/_hash_8h_source.html b/docs/d2/dad/_hash_8h_source.html index 9263762..24d8a8a 100644 --- a/docs/d2/dad/_hash_8h_source.html +++ b/docs/d2/dad/_hash_8h_source.html @@ -73,7 +73,7 @@ $(function() {
MUtils::Hash::HASH_BLAKE2_512
static const quint16 HASH_BLAKE2_512
Hash algorithm identifier.
Definition: Hash.h:42
MUtils::Hash::HASH_KECCAK_384
static const quint16 HASH_KECCAK_384
Hash algorithm identifier.
Definition: Hash.h:45
MUtils
Global MUtils namespace.
Definition: CPUFeatures.h:37
-
MUTILS_NO_COPY
#define MUTILS_NO_COPY(CLASS)
Disables copy constructor and assignment operator in the specified class. This macro should be used i...
Definition: Global.h:422
+
MUTILS_NO_COPY
#define MUTILS_NO_COPY(CLASS)
Disables copy constructor and assignment operator in the specified class. This macro should be used i...
Definition: Global.h:418
MUtils::Hash::create
MUTILS_API Hash * create(const quint16 &hashId, const char *const key=NULL)
Create instance of a hash function.
MUtils::Hash::Hash
This abstract class specifies the generic interface for all support hash algorithms.
Definition: Hash.h:57
MUtils::Hash::HASH_KECCAK_256
static const quint16 HASH_KECCAK_256
Hash algorithm identifier.
Definition: Hash.h:44
diff --git a/docs/d2/df4/namespace_m_utils_1_1_o_s.html b/docs/d2/df4/namespace_m_utils_1_1_o_s.html index b70822d..792f481 100644 --- a/docs/d2/df4/namespace_m_utils_1_1_o_s.html +++ b/docs/d2/df4/namespace_m_utils_1_1_o_s.html @@ -156,9 +156,9 @@ MUTILS_API const char * os MUTILS_API const bool & running_on_wine (void)   - -MUTILS_API const QString & known_folder (known_folder_t folder_id) -  + +MUTILS_API const QString & known_folder (const known_folder_t folder_id) +  MUTILS_API QDate current_date (void)   diff --git a/docs/d3/dc1/_o_s_support_8h.html b/docs/d3/dc1/_o_s_support_8h.html index 11e9f18..d63494e 100644 --- a/docs/d3/dc1/_o_s_support_8h.html +++ b/docs/d3/dc1/_o_s_support_8h.html @@ -186,9 +186,9 @@ MUTILS_API const char * MU MUTILS_API const bool & MUtils::OS::running_on_wine (void)   - -MUTILS_API const QString & MUtils::OS::known_folder (known_folder_t folder_id) -  + +MUTILS_API const QString & MUtils::OS::known_folder (const known_folder_t folder_id) +  MUTILS_API QDate MUtils::OS::current_date (void)   diff --git a/docs/d3/dc1/_o_s_support_8h_source.html b/docs/d3/dc1/_o_s_support_8h_source.html index 1f91198..546ae70 100644 --- a/docs/d3/dc1/_o_s_support_8h_source.html +++ b/docs/d3/dc1/_o_s_support_8h_source.html @@ -67,7 +67,7 @@ $(function() {
OSSupport.h
-Go to the documentation of this file.
1 // MuldeR's Utilities for Qt
3 // Copyright (C) 2004-2019 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //
19 // http://www.gnu.org/licenses/lgpl-2.1.txt
21 
27 #pragma once
28 
29 //MUtils
30 #include <MUtils/Global.h>
31 
32 //Qt
33 #include <QString>
34 #include <QMap>
35 #include <QDate>
36 #include <QWidget>
37 
38 //Forward declaration
39 class QFile;
40 
42 
46 namespace MUtils
47 {
51  namespace OS
52  {
56  namespace Version
57  {
61  typedef enum
62  {
63  OS_UNKNOWN = 0,
65  }
66  os_type_t;
67 
71  typedef struct _os_version_t
72  {
73  unsigned int type;
74  unsigned int versionMajor;
75  unsigned int versionMinor;
76  unsigned int versionBuild;
77  unsigned int versionSPack;
78  bool overrideFlag;
79 
80  MUTILS_API bool operator== (const _os_version_t &rhs) const;
81  MUTILS_API bool operator!= (const _os_version_t &rhs) const;
82  MUTILS_API bool operator> (const _os_version_t &rhs) const;
83  MUTILS_API bool operator>= (const _os_version_t &rhs) const;
84  MUTILS_API bool operator< (const _os_version_t &rhs) const;
85  MUTILS_API bool operator<= (const _os_version_t &rhs) const;
86  }
88 
89  //Known Windows NT versions
90  MUTILS_API extern const os_version_t WINDOWS_WIN2K;
91  MUTILS_API extern const os_version_t WINDOWS_WINXP;
92  MUTILS_API extern const os_version_t WINDOWS_XPX64;
93  MUTILS_API extern const os_version_t WINDOWS_VISTA;
94  MUTILS_API extern const os_version_t WINDOWS_WIN70;
95  MUTILS_API extern const os_version_t WINDOWS_WIN80;
96  MUTILS_API extern const os_version_t WINDOWS_WIN81;
97  MUTILS_API extern const os_version_t WINDOWS_WN100;
98 
99  //Unknown OS
100  MUTILS_API extern const os_version_t UNKNOWN_OPSYS;
101  }
102 
106  typedef enum
107  {
114  }
116 
120  typedef enum
121  {
125  }
127 
131  typedef enum
132  {
139  }
140  drive_type_t;
141 
142  //System message
143  MUTILS_API void system_message_nfo(const wchar_t *const title, const wchar_t *const text);
144  MUTILS_API void system_message_wrn(const wchar_t *const title, const wchar_t *const text);
145  MUTILS_API void system_message_err(const wchar_t *const title, const wchar_t *const text);
146 
147  //CLI Arguments
148  typedef QMap<QString,QString> ArgumentMap;
149  MUTILS_API const QStringList crack_command_line(const QString &command_line = QString());
150  MUTILS_API const ArgumentMap &arguments(void);
151 
152  //Copy file
153  typedef bool (*progress_callback_t)(const double &progress, void *const userData);
154  MUTILS_API bool copy_file(const QString &sourcePath, const QString &outputPath, const bool &overwrite = true, const progress_callback_t callback = NULL, void *const userData = NULL);
155 
156  //Get file version
157  MUTILS_API bool get_file_version(const QString fileName, quint16 *const major = NULL, quint16 *const minor = NULL, quint16 *const patch = NULL, quint16 *const build = NULL);
158 
159  //Get the OS version
160  MUTILS_API const Version::os_version_t &os_version(void);
161  MUTILS_API const char *os_friendly_name(const MUtils::OS::Version::os_version_t &os_version);
162  MUTILS_API const bool &running_on_wine(void);
163 
164  //Get known Folder
165  MUTILS_API const QString &known_folder(known_folder_t folder_id);
166 
167  //Current Date & Time
168  MUTILS_API QDate current_date(void);
169  MUTILS_API quint64 current_file_time(void);
170 
171  //Check for process elevation
172  MUTILS_API bool is_elevated(bool *bIsUacEnabled = NULL);
173  MUTILS_API bool user_is_admin(void);
174 
182  MUTILS_API int network_status(void);
183 
184  //Message handler
185  MUTILS_API bool handle_os_message(const void *const message, long *result);
186 
196  MUTILS_API void sleep_ms(const size_t &duration);
197 
198  //Is executable/library file?
199  MUTILS_API bool is_executable_file(const QString &path);
200  MUTILS_API bool is_library_file(const QString &path);
201 
202  //Shutdown & Hibernation
203  MUTILS_API bool is_hibernation_supported(void);
204  MUTILS_API bool shutdown_computer(const QString &message, const unsigned long timeout, const bool forceShutdown, const bool hibernate);
205 
206  //Free diskspace
207  MUTILS_API bool free_diskspace(const QString &path, quint64 &freeSpace);
208 
220  MUTILS_API drive_type_t get_drive_type(const QString &path, bool *fast_seeking = NULL);
221 
222  //Shell open
223  MUTILS_API bool shell_open(const QWidget *parent, const QString &url, const bool explore = false);
224  MUTILS_API bool shell_open(const QWidget *parent, const QString &url, const QString &parameters, const QString &directory, const bool explore = false);
225 
226  //Open media file
227  MUTILS_API bool open_media_file(const QString &mediaFilePath);
228 
229  //Process priority
230  MUTILS_API bool change_process_priority(const int priority);
231  MUTILS_API bool change_process_priority(const QProcess *proc, const int priority);
232 
233  //Process ID
234  MUTILS_API quint32 process_id(void);
235  MUTILS_API quint32 process_id(const QProcess *const proc);
236 
237  //Thread ID
238  MUTILS_API quint32 thread_id(void);
239  MUTILS_API quint32 thread_id(const QProcess *const proc);
240 
241  //Suspend or resume processv
242  MUTILS_API bool suspend_process(const QProcess *proc, const bool suspend);
243 
244  //System timer resolution
245  MUTILS_API bool setup_timer_resolution(const quint32 &interval = 1);
246  MUTILS_API bool reset_timer_resolution(const quint32 &interval = 1);
247 
248  //Set file time
249  MUTILS_API bool set_file_time(const QFile &file, const QDateTime &created = QDateTime(), const QDateTime &modified = QDateTime(), const QDateTime &accessed = QDateTime());
250  MUTILS_API bool set_file_time(const QString &path, const QDateTime &created = QDateTime(), const QDateTime &modified = QDateTime(), const QDateTime &accessed = QDateTime());
251 
252  //Keyboard support
253  MUTILS_API bool check_key_state_esc(void);
254 
255  //Shell notification
256  MUTILS_API void shell_change_notification(void);
257 
258  //Get file path from descriptor
259  MUTILS_API QString get_file_path(const int &fd);
260 
261  //WOW64 redirection
262  MUTILS_API bool wow64fsredir_disable(uintptr_t &oldValue);
263  MUTILS_API bool wow64fsredir_revert (const uintptr_t oldValue);
264 
265  //Environment variables
266  MUTILS_API QString get_envvar(const QString &name);
267  MUTILS_API bool set_envvar(const QString &name, const QString &value);
268 
269  //NULL device
270  MUTILS_API const QLatin1String &null_device(void);
271 
272  //Check if debugger is present
273  MUTILS_API void check_debugger(void);
274 
275  //Error handling
276  MUTILS_API void fatal_exit(const wchar_t* const errorMessage);
277  }
278 }
279 
MUTILS_API int network_status(void)
Check the network status.
+Go to the documentation of this file.
1 // MuldeR's Utilities for Qt
3 // Copyright (C) 2004-2019 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //
19 // http://www.gnu.org/licenses/lgpl-2.1.txt
21 
27 #pragma once
28 
29 //MUtils
30 #include <MUtils/Global.h>
31 
32 //Qt
33 #include <QString>
34 #include <QMap>
35 #include <QDate>
36 #include <QWidget>
37 
38 //Forward declaration
39 class QFile;
40 
42 
46 namespace MUtils
47 {
51  namespace OS
52  {
56  namespace Version
57  {
61  typedef enum
62  {
63  OS_UNKNOWN = 0,
65  }
66  os_type_t;
67 
71  typedef struct _os_version_t
72  {
73  unsigned int type;
74  unsigned int versionMajor;
75  unsigned int versionMinor;
76  unsigned int versionBuild;
77  unsigned int versionSPack;
78  bool overrideFlag;
79 
80  MUTILS_API bool operator== (const _os_version_t &rhs) const;
81  MUTILS_API bool operator!= (const _os_version_t &rhs) const;
82  MUTILS_API bool operator> (const _os_version_t &rhs) const;
83  MUTILS_API bool operator>= (const _os_version_t &rhs) const;
84  MUTILS_API bool operator< (const _os_version_t &rhs) const;
85  MUTILS_API bool operator<= (const _os_version_t &rhs) const;
86  }
88 
89  //Known Windows NT versions
90  MUTILS_API extern const os_version_t WINDOWS_WIN2K;
91  MUTILS_API extern const os_version_t WINDOWS_WINXP;
92  MUTILS_API extern const os_version_t WINDOWS_XPX64;
93  MUTILS_API extern const os_version_t WINDOWS_VISTA;
94  MUTILS_API extern const os_version_t WINDOWS_WIN70;
95  MUTILS_API extern const os_version_t WINDOWS_WIN80;
96  MUTILS_API extern const os_version_t WINDOWS_WIN81;
97  MUTILS_API extern const os_version_t WINDOWS_WN100;
98 
99  //Unknown OS
100  MUTILS_API extern const os_version_t UNKNOWN_OPSYS;
101  }
102 
106  typedef enum
107  {
114  }
116 
120  typedef enum
121  {
125  }
127 
131  typedef enum
132  {
139  }
140  drive_type_t;
141 
142  //System message
143  MUTILS_API void system_message_nfo(const wchar_t *const title, const wchar_t *const text);
144  MUTILS_API void system_message_wrn(const wchar_t *const title, const wchar_t *const text);
145  MUTILS_API void system_message_err(const wchar_t *const title, const wchar_t *const text);
146 
147  //CLI Arguments
148  typedef QMap<QString,QString> ArgumentMap;
149  MUTILS_API const QStringList crack_command_line(const QString &command_line = QString());
150  MUTILS_API const ArgumentMap &arguments(void);
151 
152  //Copy file
153  typedef bool (*progress_callback_t)(const double &progress, void *const userData);
154  MUTILS_API bool copy_file(const QString &sourcePath, const QString &outputPath, const bool &overwrite = true, const progress_callback_t callback = NULL, void *const userData = NULL);
155 
156  //Get file version
157  MUTILS_API bool get_file_version(const QString fileName, quint16 *const major = NULL, quint16 *const minor = NULL, quint16 *const patch = NULL, quint16 *const build = NULL);
158 
159  //Get the OS version
160  MUTILS_API const Version::os_version_t &os_version(void);
161  MUTILS_API const char *os_friendly_name(const MUtils::OS::Version::os_version_t &os_version);
162  MUTILS_API const bool &running_on_wine(void);
163 
164  //Get known Folder
165  MUTILS_API const QString &known_folder(const known_folder_t folder_id);
166 
167  //Current Date & Time
168  MUTILS_API QDate current_date(void);
169  MUTILS_API quint64 current_file_time(void);
170 
171  //Check for process elevation
172  MUTILS_API bool is_elevated(bool *bIsUacEnabled = NULL);
173  MUTILS_API bool user_is_admin(void);
174 
182  MUTILS_API int network_status(void);
183 
184  //Message handler
185  MUTILS_API bool handle_os_message(const void *const message, long *result);
186 
196  MUTILS_API void sleep_ms(const size_t &duration);
197 
198  //Is executable/library file?
199  MUTILS_API bool is_executable_file(const QString &path);
200  MUTILS_API bool is_library_file(const QString &path);
201 
202  //Shutdown & Hibernation
203  MUTILS_API bool is_hibernation_supported(void);
204  MUTILS_API bool shutdown_computer(const QString &message, const unsigned long timeout, const bool forceShutdown, const bool hibernate);
205 
206  //Free diskspace
207  MUTILS_API bool free_diskspace(const QString &path, quint64 &freeSpace);
208 
220  MUTILS_API drive_type_t get_drive_type(const QString &path, bool *fast_seeking = NULL);
221 
222  //Shell open
223  MUTILS_API bool shell_open(const QWidget *parent, const QString &url, const bool explore = false);
224  MUTILS_API bool shell_open(const QWidget *parent, const QString &url, const QString &parameters, const QString &directory, const bool explore = false);
225 
226  //Open media file
227  MUTILS_API bool open_media_file(const QString &mediaFilePath);
228 
229  //Process priority
230  MUTILS_API bool change_process_priority(const int priority);
231  MUTILS_API bool change_process_priority(const QProcess *proc, const int priority);
232 
233  //Process ID
234  MUTILS_API quint32 process_id(void);
235  MUTILS_API quint32 process_id(const QProcess *const proc);
236 
237  //Thread ID
238  MUTILS_API quint32 thread_id(void);
239  MUTILS_API quint32 thread_id(const QProcess *const proc);
240 
241  //Suspend or resume processv
242  MUTILS_API bool suspend_process(const QProcess *proc, const bool suspend);
243 
244  //System timer resolution
245  MUTILS_API bool setup_timer_resolution(const quint32 &interval = 1);
246  MUTILS_API bool reset_timer_resolution(const quint32 &interval = 1);
247 
248  //Set file time
249  MUTILS_API bool set_file_time(const QFile &file, const QDateTime &created = QDateTime(), const QDateTime &modified = QDateTime(), const QDateTime &accessed = QDateTime());
250  MUTILS_API bool set_file_time(const QString &path, const QDateTime &created = QDateTime(), const QDateTime &modified = QDateTime(), const QDateTime &accessed = QDateTime());
251 
252  //Keyboard support
253  MUTILS_API bool check_key_state_esc(void);
254 
255  //Shell notification
256  MUTILS_API void shell_change_notification(void);
257 
258  //Get file path from descriptor
259  MUTILS_API QString get_file_path(const int &fd);
260 
261  //WOW64 redirection
262  MUTILS_API bool wow64fsredir_disable(uintptr_t &oldValue);
263  MUTILS_API bool wow64fsredir_revert (const uintptr_t oldValue);
264 
265  //Environment variables
266  MUTILS_API QString get_envvar(const QString &name);
267  MUTILS_API bool set_envvar(const QString &name, const QString &value);
268 
269  //NULL device
270  MUTILS_API const QLatin1String &null_device(void);
271 
272  //Check if debugger is present
273  MUTILS_API void check_debugger(void);
274 
275  //Error handling
276  MUTILS_API void fatal_exit(const wchar_t* const errorMessage);
277  }
278 }
279 
MUTILS_API int network_status(void)
Check the network status.
MUTILS_API const os_version_t UNKNOWN_OPSYS
Operating system version constant.
Local application data (non-roaming)
Definition: OSSupport.h:109
unsigned int versionMinor
The minor version of the underlaying operating system.
Definition: OSSupport.h:75
diff --git a/docs/d4/d85/_job_object_8h_source.html b/docs/d4/d85/_job_object_8h_source.html index c825c4f..1d9ee03 100644 --- a/docs/d4/d85/_job_object_8h_source.html +++ b/docs/d4/d85/_job_object_8h_source.html @@ -70,7 +70,7 @@ $(function() { Go to the documentation of this file.
1 // MuldeR's Utilities for Qt
3 // Copyright (C) 2004-2019 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //
19 // http://www.gnu.org/licenses/lgpl-2.1.txt
21 
31 #pragma once
32 
33 #include <MUtils/Global.h>
34 
35 class QProcess;
36 
37 namespace MUtils
38 {
46  class MUTILS_API JobObject
47  {
48  public:
54  JobObject(void);
55 
61  ~JobObject(void);
62 
70  bool isObjectCreated(void);
71 
81  bool addProcessToJob(const QProcess *const process);
82 
92  bool terminateJob(const quint32 &exitCode);
93 
94  private:
95  uintptr_t m_jobPtr;
97  };
98 }
This file contains miscellaneous functions that are generally useful for Qt-based applications...
This class represents a job object.
Definition: JobObject.h:46
Global MUtils namespace.
Definition: CPUFeatures.h:37
-
#define MUTILS_NO_COPY(CLASS)
Disables copy constructor and assignment operator in the specified class. This macro should be used i...
Definition: Global.h:422
+
#define MUTILS_NO_COPY(CLASS)
Disables copy constructor and assignment operator in the specified class. This macro should be used i...
Definition: Global.h:418
-Go to the documentation of this file.
1 // MuldeR's Utilities for Qt
3 // Copyright (C) 2004-2019 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //
19 // http://www.gnu.org/licenses/lgpl-2.1.txt
21 
27 #pragma once
28 
29 #include <QString>
30 
31 //Forward Declarations
32 class QProcess;
33 class QDir;
34 template<typename K, typename V> class QHash;
35 
37 
41  //Interface version
42 #define MUTILS_INTERFACE 2
43 
44 //Build key
45 #define MUTILS_BUILD_KEY_HELPER(X,Y) X##" "##Y
46 #define MUTILS_BUILD_KEY MUTILS_BUILD_KEY_HELPER(__DATE__, __TIME__)
47 
48 //MUtils API
49 #ifdef _MSC_VER
50 # ifdef MUTILS_DLL_EXPORT
51 # define MUTILS_API __declspec(dllexport)
52 # else
53 # ifndef MUTILS_STATIC_LIB
54 # define MUTILS_API __declspec(dllimport)
55 # else
56 # define MUTILS_API /*static lib*/
57 # endif
58 # endif
59 #else
60 # define MUTILS_API
61 #endif
62 
63 //Check Debug Flags
64 #if defined(_DEBUG) || defined(DEBUG) || (!defined(NDEBUG))
65 # define MUTILS_DEBUG (1)
66 # if defined(NDEBUG) || defined(QT_NO_DEBUG) || (!defined(QT_DEBUG))
67 # error Inconsistent DEBUG flags have been detected!
68 # endif
69 #else
70 # define MUTILS_DEBUG (0)
71 # if (!defined(NDEBUG)) || (!defined(QT_NO_DEBUG)) || defined(QT_DEBUG)
72 # error Inconsistent DEBUG flags have been detected!
73 # endif
74 #endif
75 
76 //Check CPU options
77 #if defined(_MSC_VER) && (!defined(__INTELLISENSE__)) && (!defined(_M_X64)) && defined(_M_IX86_FP)
78  #if (_M_IX86_FP != 0)
79  #error We should not enabled SSE or SSE2 in release builds!
80  #endif
81 #endif
82 
83 //Library initializer
84 #define MUTILS_GLUE_NAME_HELPER(X,Y) X##Y
85 #define MUTILS_GLUE_NAME(X,Y) MUTILS_GLUE_NAME_HELPER(X,Y)
86 #if MUTILS_DEBUG
87 #define MUTILS_INITIALIZER MUTILS_GLUE_NAME(initialize_d, MUTILS_INTERFACE)
88 #else
89 #define MUTILS_INITIALIZER MUTILS_GLUE_NAME(initialize_r, MUTILS_INTERFACE)
90 #endif
91 
92 //Compiler warnings
93 #define MUTILS_MAKE_STRING_HELPER(X) #X
94 #define MUTILS_MAKE_STRING(X) MUTILS_MAKE_STRING_HELPER(X)
95 #define MUTILS_COMPILER_WARNING(TXT) __pragma(message(__FILE__ "(" MUTILS_MAKE_STRING(__LINE__) ") : warning: " TXT))
96 
100 
105 namespace MUtils
106 {
110  typedef struct _fp_parts_t { double parts[2]; } fp_parts_t;
111 
119  MUTILS_API const QString& temp_folder(void);
120 
134  MUTILS_API void init_process(QProcess &process, const QString &wokringDir, const bool bReplaceTempDir = true, const QStringList *const extraPaths = NULL, const QHash<QString, QString> *const extraEnv = NULL);
135 
143  MUTILS_API quint32 next_rand_u32(void);
144  MUTILS_API quint32 next_rand_u32(const quint32 max);
145 
153  MUTILS_API quint64 next_rand_u64(void);
154 
164  MUTILS_API QString next_rand_str(const bool &bLong = false);
165 
179  MUTILS_API QString make_temp_file(const QString &basePath, const QString &extension, const bool placeholder = false);
180  MUTILS_API QString make_temp_file(const QDir &basePath, const QString &extension, const bool placeholder = false);
181 
197  MUTILS_API QString make_unique_file(const QString &basePath, const QString &baseName, const QString &extension, const bool fancy = false, const bool placeholder = false);
198  MUTILS_API QString make_unique_file(const QDir &basePath, const QString &baseName, const QString &extension, const bool fancy = false, const bool placeholder = false);
199 
207  MUTILS_API bool parity(quint32 value);
208 
218  MUTILS_API bool remove_file(const QString &fileName);
219 
231  MUTILS_API bool remove_directory(const QString &folderPath, const bool &recursive);
232 
242  MUTILS_API QString& trim_right(QString &str);
243 
253  MUTILS_API QString& trim_left(QString &str);
254 
264  MUTILS_API QString trim_right(const QString &str);
265 
275  MUTILS_API QString trim_left(const QString &str);
276 
286  MUTILS_API void natural_string_sort(QStringList &list, const bool bIgnoreCase);
287 
299  MUTILS_API QString clean_file_name(const QString &name, const bool &pretty);
300 
312  MUTILS_API QString clean_file_path(const QString &path, const bool &pretty);
313 
325  MUTILS_API bool regexp_parse_uint32(const QRegExp &regexp, quint32 &value);
326  MUTILS_API bool regexp_parse_int32(const QRegExp &regexp, qint32 &value);
327  MUTILS_API bool regexp_parse_uint32(const QRegExp &regexp, quint32 &value, const size_t &offset);
328  MUTILS_API bool regexp_parse_int32(const QRegExp &regexp, qint32 &value, const size_t &offset);
329 
343  MUTILS_API bool regexp_parse_uint32(const QRegExp &regexp, quint32 *values, const size_t &count);
344  MUTILS_API bool regexp_parse_int32(const QRegExp &regexp, qint32 *values, const size_t &count);
345  MUTILS_API bool regexp_parse_uint32(const QRegExp &regexp, quint32 *values, const size_t &offset, const size_t &count);
346  MUTILS_API bool regexp_parse_int32(const QRegExp &regexp, qint32 *values, const size_t &offset, const size_t &count);
347 
357  MUTILS_API QStringList available_codepages(const bool &noAliases = true);
358 
368  MUTILS_API fp_parts_t break_fp(const double value);
369 
370  //Internal (do *not* call directly!)
371  namespace Internal
372  {
373  MUTILS_API int MUTILS_INITIALIZER(const unsigned int interfaceId, const bool debugFlag, const char *const buildKey);
374  static const int s_initializedFlag = MUTILS_INITIALIZER(MUTILS_INTERFACE, MUTILS_DEBUG, MUTILS_BUILD_KEY);
375  }
376 }
377 
379 
382 #define MUTILS_DELETE(PTR) do { if((PTR)) { delete (PTR); (PTR) = NULL; } } while(0)
383 
386 #define MUTILS_DELETE_ARRAY(PTR) do { if((PTR)) { delete [] (PTR); (PTR) = NULL; } } while(0)
387 
390 #define MUTILS_ZERO_MEMORY(PTR) memset(&(PTR), 0, sizeof((PTR)))
391 
394 #define MUTILS_WCHR(STR) (reinterpret_cast<const wchar_t*>((STR).utf16()))
395 
398 #define MUTILS_UTF8(STR) ((STR).toUtf8().constData())
399 
402 #define MUTILS_L1STR(STR) ((STR).toLatin1().constData())
403 
406 #define MUTILS_QSTR(STR) (QString::fromUtf16(reinterpret_cast<const unsigned short*>((STR))))
407 
410 #define MUTILS_BOOL2STR(X) ((X) ? "1" : "0")
411 
414 #define MUTILS_BOOLIFY(X) (!(!(X)))
415 
418 #define MUTILS_ARR2LEN(X) (sizeof((X)) / sizeof((X)[0]))
419 
422 #define MUTILS_NO_COPY(CLASS) \
423  CLASS(const CLASS &) { throw "Copy constructor is disabled!"; } \
424  CLASS &operator=(const CLASS &) { throw "Assignment operator is disabled!"; }
MUTILS_API QStringList available_codepages(const bool &noAliases=true)
Retrieve a list of all available codepages.
+Go to the documentation of this file.
1 // MuldeR's Utilities for Qt
3 // Copyright (C) 2004-2019 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //
19 // http://www.gnu.org/licenses/lgpl-2.1.txt
21 
27 #pragma once
28 
29 #include <QString>
30 
31 //Forward Declarations
32 class QProcess;
33 class QDir;
34 template<typename K, typename V> class QHash;
35 
37 
41  //Interface version
42 #define MUTILS_INTERFACE 2
43 
44 //MUtils API
45 #ifdef _MSC_VER
46 # ifdef MUTILS_DLL_EXPORT
47 # define MUTILS_API __declspec(dllexport)
48 # else
49 # ifndef MUTILS_STATIC_LIB
50 # define MUTILS_API __declspec(dllimport)
51 # else
52 # define MUTILS_API /*static lib*/
53 # endif
54 # endif
55 #else
56 # define MUTILS_API
57 #endif
58 
59 //Check Debug Flags
60 #if defined(_DEBUG) || defined(DEBUG) || (!defined(NDEBUG))
61 # define MUTILS_DEBUG (1)
62 # if defined(NDEBUG) || defined(QT_NO_DEBUG) || (!defined(QT_DEBUG))
63 # error Inconsistent DEBUG flags have been detected!
64 # endif
65 #else
66 # define MUTILS_DEBUG (0)
67 # if (!defined(NDEBUG)) || (!defined(QT_NO_DEBUG)) || defined(QT_DEBUG)
68 # error Inconsistent DEBUG flags have been detected!
69 # endif
70 #endif
71 
72 //Check CPU options
73 #if defined(_MSC_VER) && (!defined(__INTELLISENSE__)) && (!defined(_M_X64)) && defined(_M_IX86_FP)
74  #if (_M_IX86_FP != 0)
75  #error We should not enabled SSE or SSE2 in release builds!
76  #endif
77 #endif
78 
79 //Library initializer
80 #define MUTILS_GLUE_NAME_HELPER(X,Y) X##Y
81 #define MUTILS_GLUE_NAME(X,Y) MUTILS_GLUE_NAME_HELPER(X,Y)
82 #if MUTILS_DEBUG
83 #define MUTILS_INITIALIZER MUTILS_GLUE_NAME(initialize_d, MUTILS_INTERFACE)
84 #else
85 #define MUTILS_INITIALIZER MUTILS_GLUE_NAME(initialize_r, MUTILS_INTERFACE)
86 #endif
87 
88 //Compiler warnings
89 #define MUTILS_MAKE_STRING_HELPER(X) #X
90 #define MUTILS_MAKE_STRING(X) MUTILS_MAKE_STRING_HELPER(X)
91 #define MUTILS_COMPILER_WARNING(TXT) __pragma(message(__FILE__ "(" MUTILS_MAKE_STRING(__LINE__) ") : warning: " TXT))
92 
96 
101 namespace MUtils
102 {
106  typedef struct _fp_parts_t { double parts[2]; } fp_parts_t;
107 
115  MUTILS_API const QString& temp_folder(void);
116 
130  MUTILS_API void init_process(QProcess &process, const QString &wokringDir, const bool bReplaceTempDir = true, const QStringList *const extraPaths = NULL, const QHash<QString, QString> *const extraEnv = NULL);
131 
139  MUTILS_API quint32 next_rand_u32(void);
140  MUTILS_API quint32 next_rand_u32(const quint32 max);
141 
149  MUTILS_API quint64 next_rand_u64(void);
150 
160  MUTILS_API QString next_rand_str(const bool &bLong = false);
161 
175  MUTILS_API QString make_temp_file(const QString &basePath, const QString &extension, const bool placeholder = false);
176  MUTILS_API QString make_temp_file(const QDir &basePath, const QString &extension, const bool placeholder = false);
177 
193  MUTILS_API QString make_unique_file(const QString &basePath, const QString &baseName, const QString &extension, const bool fancy = false, const bool placeholder = false);
194  MUTILS_API QString make_unique_file(const QDir &basePath, const QString &baseName, const QString &extension, const bool fancy = false, const bool placeholder = false);
195 
203  MUTILS_API bool parity(quint32 value);
204 
214  MUTILS_API bool remove_file(const QString &fileName);
215 
227  MUTILS_API bool remove_directory(const QString &folderPath, const bool &recursive);
228 
238  MUTILS_API QString& trim_right(QString &str);
239 
249  MUTILS_API QString& trim_left(QString &str);
250 
260  MUTILS_API QString trim_right(const QString &str);
261 
271  MUTILS_API QString trim_left(const QString &str);
272 
282  MUTILS_API void natural_string_sort(QStringList &list, const bool bIgnoreCase);
283 
295  MUTILS_API QString clean_file_name(const QString &name, const bool &pretty);
296 
308  MUTILS_API QString clean_file_path(const QString &path, const bool &pretty);
309 
321  MUTILS_API bool regexp_parse_uint32(const QRegExp &regexp, quint32 &value);
322  MUTILS_API bool regexp_parse_int32(const QRegExp &regexp, qint32 &value);
323  MUTILS_API bool regexp_parse_uint32(const QRegExp &regexp, quint32 &value, const size_t &offset);
324  MUTILS_API bool regexp_parse_int32(const QRegExp &regexp, qint32 &value, const size_t &offset);
325 
339  MUTILS_API bool regexp_parse_uint32(const QRegExp &regexp, quint32 *values, const size_t &count);
340  MUTILS_API bool regexp_parse_int32(const QRegExp &regexp, qint32 *values, const size_t &count);
341  MUTILS_API bool regexp_parse_uint32(const QRegExp &regexp, quint32 *values, const size_t &offset, const size_t &count);
342  MUTILS_API bool regexp_parse_int32(const QRegExp &regexp, qint32 *values, const size_t &offset, const size_t &count);
343 
353  MUTILS_API QStringList available_codepages(const bool &noAliases = true);
354 
364  MUTILS_API fp_parts_t break_fp(const double value);
365 
366  //Internal (do *not* call directly!)
367  namespace Internal
368  {
369  MUTILS_API unsigned int MUTILS_INITIALIZER(const unsigned int interfaceId);
370  static const unsigned int init_flag = MUTILS_INITIALIZER(MUTILS_INTERFACE);
371  }
372 }
373 
375 
378 #define MUTILS_DELETE(PTR) do { if((PTR)) { delete (PTR); (PTR) = NULL; } } while(0)
379 
382 #define MUTILS_DELETE_ARRAY(PTR) do { if((PTR)) { delete [] (PTR); (PTR) = NULL; } } while(0)
383 
386 #define MUTILS_ZERO_MEMORY(PTR) memset(&(PTR), 0, sizeof((PTR)))
387 
390 #define MUTILS_WCHR(STR) (reinterpret_cast<const wchar_t*>((STR).utf16()))
391 
394 #define MUTILS_UTF8(STR) ((STR).toUtf8().constData())
395 
398 #define MUTILS_L1STR(STR) ((STR).toLatin1().constData())
399 
402 #define MUTILS_QSTR(STR) (QString::fromUtf16(reinterpret_cast<const unsigned short*>((STR))))
403 
406 #define MUTILS_BOOL2STR(X) ((X) ? "1" : "0")
407 
410 #define MUTILS_BOOLIFY(X) (!(!(X)))
411 
414 #define MUTILS_ARR2LEN(X) (sizeof((X)) / sizeof((X)[0]))
415 
418 #define MUTILS_NO_COPY(CLASS) \
419  CLASS(const CLASS &) { throw "Copy constructor is disabled!"; } \
420  CLASS &operator=(const CLASS &) { throw "Assignment operator is disabled!"; }
MUTILS_API QStringList available_codepages(const bool &noAliases=true)
Retrieve a list of all available codepages.
struct MUtils::_fp_parts_t fp_parts_t
This struct containes the parts (integral and fractional part) of a floating-point number...
MUTILS_API QString next_rand_str(const bool &bLong=false)
Generates a random string.
MUTILS_API bool remove_file(const QString &fileName)
Deletes the specified file.
MUTILS_API QString clean_file_path(const QString &path, const bool &pretty)
Clean up a file path string.
-
This struct containes the parts (integral and fractional part) of a floating-point number...
Definition: Global.h:110
+
This struct containes the parts (integral and fractional part) of a floating-point number...
Definition: Global.h:106
MUTILS_API void natural_string_sort(QStringList &list, const bool bIgnoreCase)
Sort a list of strings using "natural ordering" algorithm.
MUTILS_API bool regexp_parse_uint32(const QRegExp &regexp, quint32 &value)
Parse regular expression results.
MUTILS_API bool parity(quint32 value)
Computes the parity of the given unsigned 32-Bit value.
diff --git a/include/MUtils/OSSupport.h b/include/MUtils/OSSupport.h index b1d558a..8200e06 100644 --- a/include/MUtils/OSSupport.h +++ b/include/MUtils/OSSupport.h @@ -162,7 +162,7 @@ namespace MUtils MUTILS_API const bool &running_on_wine(void); //Get known Folder - MUTILS_API const QString &known_folder(known_folder_t folder_id); + MUTILS_API const QString &known_folder(const known_folder_t folder_id); //Current Date & Time MUTILS_API QDate current_date(void); diff --git a/src/OSSupport_Win32.cpp b/src/OSSupport_Win32.cpp index 862bf02..8a1af03 100644 --- a/src/OSSupport_Win32.cpp +++ b/src/OSSupport_Win32.cpp @@ -690,43 +690,131 @@ const bool &MUtils::OS::running_on_wine(void) static QReadWriteLock g_known_folders_lock; static QScopedPointer> g_known_folders_data; -typedef HRESULT (WINAPI *SHGetKnownFolderPath_t)(const GUID &rfid, DWORD dwFlags, HANDLE hToken, PWSTR *ppszPath); -typedef HRESULT (WINAPI *SHGetFolderPath_t) (HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath); +typedef HRESULT (WINAPI *SHGetKnownFolderPathProc)(const GUID &rfid, DWORD dwFlags, HANDLE hToken, PWSTR *ppszPath); +typedef HRESULT (WINAPI *SHGetFolderPathProc)(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath); -const QString &MUtils::OS::known_folder(known_folder_t folder_id) +static const struct { - typedef enum { KF_FLAG_CREATE = 0x00008000 } kf_flags_t; - - struct + INT32 csidl; + GUID kfuid; +} +s_known_folders_lut[] = +{ + { 0x001A, { 0x3EB685DB, 0x65F9, 0x4CF6, { 0xA0, 0x3A, 0xE3, 0xEF, 0x65, 0x72, 0x9F, 0x3D } } }, //CSIDL_APPDATA + { 0x001C, { 0xF1B32785, 0x6FBA, 0x4FCF, { 0x9D, 0x55, 0x7B, 0x8E, 0x7F, 0x15, 0x70, 0x91 } } }, //CSIDL_LOCAL_APPDATA + { 0x0028, { 0x5E6C858F, 0x0E22, 0x4760, { 0x9A, 0xFE, 0xEA, 0x33, 0x17, 0xB6, 0x71, 0x73 } } }, //CSIDL_PROFILE + { 0x0026, { 0x905E63B6, 0xC1BF, 0x494E, { 0xB2, 0x9C, 0x65, 0xB7, 0x32, 0xD3, 0xD2, 0x1A } } }, //CSIDL_PROGRAM_FILES + { 0x0025, { 0x1AC14E77, 0x02E7, 0x4E5D, { 0xB7, 0x44, 0x2E, 0xB1, 0xAE, 0x51, 0x98, 0xB7 } } }, //CSIDL_SYSTEM_FOLDER + { 0x0024, { 0xF38BF404, 0x1D43, 0x42F2, { 0x93, 0x05, 0x67, 0xDE, 0x0B, 0x28, 0xFC, 0x23 } } }, //CSIDL_WINDOWS_FOLDER +}; + +static QString known_folder_fallback(const size_t folderId) +{ + static const DWORD s_shgfpTypes[3] = { - const int csidl; - const GUID guid; - } - static s_folders[] = - { - { 0x001a, {0x3EB685DB,0x65F9,0x4CF6,{0xA0,0x3A,0xE3,0xEF,0x65,0x72,0x9F,0x3D}} }, //CSIDL_APPDATA - { 0x001c, {0xF1B32785,0x6FBA,0x4FCF,{0x9D,0x55,0x7B,0x8E,0x7F,0x15,0x70,0x91}} }, //CSIDL_LOCAL_APPDATA - { 0x0028, {0x5E6C858F,0x0E22,0x4760,{0x9A,0xFE,0xEA,0x33,0x17,0xB6,0x71,0x73}} }, //CSIDL_PROFILE - { 0x0026, {0x905e63b6,0xc1bf,0x494e,{0xb2,0x9c,0x65,0xb7,0x32,0xd3,0xd2,0x1a}} }, //CSIDL_PROGRAM_FILES - { 0x0025, {0x1AC14E77,0x02E7,0x4E5D,{0xB7,0x44,0x2E,0xB1,0xAE,0x51,0x98,0xB7}} }, //CSIDL_SYSTEM_FOLDER - { 0x0024, {0xF38BF404,0x1D43,0x42F2,{0x93,0x05,0x67,0xDE,0x0B,0x28,0xFC,0x23}} }, //CSIDL_WINDOWS_FOLDER + 0, /*SHGFP_TYPE_CURRENT*/ + 1, /*SHGFP_TYPE_DEFAULT*/ + MAXDWORD }; - size_t folderId = size_t(-1); - - switch(folder_id) + static const INT32 s_shgfpFlags[3] = { - case FOLDER_ROAMING_DATA: folderId = 0; break; - case FOLDER_LOCALAPPDATA: folderId = 1; break; - case FOLDER_USER_PROFILE: folderId = 2; break; - case FOLDER_PROGRAMFILES: folderId = 3; break; - case FOLDER_SYSTEMFOLDER: folderId = 4; break; - case FOLDER_SYSTROOT_DIR: folderId = 5; break; - default: - qWarning("Invalid 'known' folder was requested!"); - return Internal::g_empty; + 0x0000, /*No extra flags*/ + 0x8000, /*SHGFP_FLAG_CREATE*/ + MAXINT32 + }; + + const SHGetFolderPathProc getFolderPath = MUtils::Win32Utils::resolve(QLatin1String("shell32"), QLatin1String("SHGetFolderPathW")); + if (getFolderPath) + { + QVector pathBuffer(MAX_PATH); + for (size_t i = 0; s_shgfpTypes[i] != MAXDWORD; ++i) + { + for (size_t j = 0; s_shgfpFlags[j] != MAXINT32; ++j) + { + if (getFolderPath(NULL, s_known_folders_lut[folderId].csidl | s_shgfpFlags[j], NULL, s_shgfpTypes[i], pathBuffer.data()) == S_OK) + { + //MessageBoxW(0, path, L"SHGetFolderPathW", MB_TOPMOST); + const QDir folderPathTemp = QDir(QDir::fromNativeSeparators(MUTILS_QSTR(pathBuffer.data()))); + if (folderPathTemp.exists()) + { + return folderPathTemp.canonicalPath(); + } + } + } + } } + return QString(); /*failed!*/ +} + +static QString known_folder_detect(const size_t folderId) +{ + typedef enum + { + KF_FLAG_DEFAULT = 0x00000000, + KF_FLAG_DEFAULT_PATH = 0x00000400, + KF_FLAG_CREATE = 0x00008000 + } + kf_flag_t; + + static const DWORD s_kfFlags[5] = + { + KF_FLAG_DEFAULT, + KF_FLAG_CREATE, + KF_FLAG_DEFAULT_PATH, + KF_FLAG_DEFAULT_PATH | KF_FLAG_CREATE, + MAXDWORD + }; + + const SHGetKnownFolderPathProc getKnownFolderPath = MUtils::Win32Utils::resolve(QLatin1String("shell32"), QLatin1String("SHGetKnownFolderPath")); + if (getKnownFolderPath) + { + for (size_t i = 0; s_kfFlags[i] != MAXDWORD; ++i) + { + WCHAR* path = NULL; + if (getKnownFolderPath(s_known_folders_lut[folderId].kfuid, s_kfFlags[i], NULL, &path) == S_OK) + { + //MessageBoxW(0, path, L"SHGetKnownFolderPath", MB_TOPMOST); + const QDir folderPathTemp = QDir(QDir::fromNativeSeparators(MUTILS_QSTR(path))); + CoTaskMemFree(path); + if (folderPathTemp.exists()) + { + return folderPathTemp.canonicalPath(); + } + } + } + } + + return known_folder_fallback(folderId); /*fallback!*/ +} + +static size_t known_folder_decode(const MUtils::OS::known_folder_t folder_id) +{ + switch (folder_id) + { + case MUtils::OS::FOLDER_ROAMING_DATA: return 0U; + case MUtils::OS::FOLDER_LOCALAPPDATA: return 1U; + case MUtils::OS::FOLDER_USER_PROFILE: return 2U; + case MUtils::OS::FOLDER_PROGRAMFILES: return 3U; + case MUtils::OS::FOLDER_SYSTEMFOLDER: return 4U; + case MUtils::OS::FOLDER_SYSTROOT_DIR: return 5U; + default: + qWarning("Invalid 'known' folder was requested!"); + return SIZE_MAX; + } +} + +const QString &MUtils::OS::known_folder(const known_folder_t folder_id) +{ + //Map to numeric id + const size_t folderId = known_folder_decode(folder_id); + if (folderId == SIZE_MAX) + { + return Internal::g_empty; + } + + //Obtain read lock QReadLocker readLock(&g_known_folders_lock); //Already in cache? @@ -757,41 +845,8 @@ const QString &MUtils::OS::known_folder(known_folder_t folder_id) g_known_folders_data.reset(new QHash()); } - QString folderPath; - - //Try SHGetKnownFolderPath() first! - if(const SHGetKnownFolderPath_t known_folders_fpGetKnownFolderPath = MUtils::Win32Utils::resolve(QLatin1String("shell32"), QLatin1String("SHGetKnownFolderPath"))) - { - WCHAR *path = NULL; - if(known_folders_fpGetKnownFolderPath(s_folders[folderId].guid, KF_FLAG_CREATE, NULL, &path) == S_OK) - { - //MessageBoxW(0, path, L"SHGetKnownFolderPath", MB_TOPMOST); - const QDir folderTemp = QDir(QDir::fromNativeSeparators(MUTILS_QSTR(path))); - if(folderTemp.exists()) - { - folderPath = folderTemp.canonicalPath(); - } - CoTaskMemFree(path); - } - } - - //Fall back to SHGetFolderPathW() - if (folderPath.isEmpty()) - { - if (const SHGetFolderPath_t known_folders_fpGetFolderPath = MUtils::Win32Utils::resolve(QLatin1String("shell32"), QLatin1String("SHGetFolderPathW"))) - { - QScopedArrayPointer path(new WCHAR[4096]); - if (known_folders_fpGetFolderPath(NULL, s_folders[folderId].csidl | CSIDL_FLAG_CREATE, NULL, NULL, path.data()) == S_OK) - { - //MessageBoxW(0, path, L"SHGetFolderPathW", MB_TOPMOST); - const QDir folderTemp = QDir(QDir::fromNativeSeparators(MUTILS_QSTR(path.data()))); - if (folderTemp.exists()) - { - folderPath = folderTemp.canonicalPath(); - } - } - } - } + //Detect path now! + const QString folderPath = known_folder_detect(folderId); //Update cache if (!folderPath.isEmpty())