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() {
static const quint16 HASH_BLAKE2_512
Hash algorithm identifier.
Definition: Hash.h:42
static const quint16 HASH_KECCAK_384
Hash algorithm identifier.
Definition: Hash.h:45
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
MUTILS_API Hash * create(const quint16 &hashId, const char *const key=NULL)
Create instance of a hash function.
This abstract class specifies the generic interface for all support hash algorithms.
Definition: Hash.h:57
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. 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); 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); 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); 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); 162 MUTILS_API const bool &running_on_wine( void); 168 MUTILS_API QDate current_date( void); 169 MUTILS_API quint64 current_file_time( void); 172 MUTILS_API bool is_elevated( bool *bIsUacEnabled = NULL); 173 MUTILS_API bool user_is_admin( void); 185 MUTILS_API bool handle_os_message( const void * const message, long *result); 196 MUTILS_API void sleep_ms( const size_t &duration); 199 MUTILS_API bool is_executable_file( const QString &path); 200 MUTILS_API bool is_library_file( const QString &path); 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); 207 MUTILS_API bool free_diskspace( const QString &path, quint64 &freeSpace); 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 ¶meters, const QString &directory, const bool explore = false); 227 MUTILS_API bool open_media_file( const QString &mediaFilePath); 230 MUTILS_API bool change_process_priority( const int priority); 231 MUTILS_API bool change_process_priority( const QProcess *proc, const int priority); 234 MUTILS_API quint32 process_id( void); 235 MUTILS_API quint32 process_id( const QProcess * const proc); 238 MUTILS_API quint32 thread_id( void); 239 MUTILS_API quint32 thread_id( const QProcess * const proc); 242 MUTILS_API bool suspend_process( const QProcess *proc, const bool suspend); 245 MUTILS_API bool setup_timer_resolution( const quint32 &interval = 1); 246 MUTILS_API bool reset_timer_resolution( const quint32 &interval = 1); 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()); 253 MUTILS_API bool check_key_state_esc( void); 256 MUTILS_API void shell_change_notification( void); 259 MUTILS_API QString get_file_path( const int &fd); 262 MUTILS_API bool wow64fsredir_disable(uintptr_t &oldValue); 263 MUTILS_API bool wow64fsredir_revert ( const uintptr_t oldValue); 266 MUTILS_API QString get_envvar( const QString &name); 267 MUTILS_API bool set_envvar( const QString &name, const QString &value); 270 MUTILS_API const QLatin1String &null_device( void); 273 MUTILS_API void check_debugger( void); 276 MUTILS_API void fatal_exit( const wchar_t* const errorMessage); MUTILS_API int network_status(void) Check the network status.
+ Go to the documentation of this file. 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); 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); 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); 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); 162 MUTILS_API const bool &running_on_wine( void); 165 MUTILS_API const QString &known_folder( const known_folder_t folder_id); 168 MUTILS_API QDate current_date( void); 169 MUTILS_API quint64 current_file_time( void); 172 MUTILS_API bool is_elevated( bool *bIsUacEnabled = NULL); 173 MUTILS_API bool user_is_admin( void); 185 MUTILS_API bool handle_os_message( const void * const message, long *result); 196 MUTILS_API void sleep_ms( const size_t &duration); 199 MUTILS_API bool is_executable_file( const QString &path); 200 MUTILS_API bool is_library_file( const QString &path); 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); 207 MUTILS_API bool free_diskspace( const QString &path, quint64 &freeSpace); 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 ¶meters, const QString &directory, const bool explore = false); 227 MUTILS_API bool open_media_file( const QString &mediaFilePath); 230 MUTILS_API bool change_process_priority( const int priority); 231 MUTILS_API bool change_process_priority( const QProcess *proc, const int priority); 234 MUTILS_API quint32 process_id( void); 235 MUTILS_API quint32 process_id( const QProcess * const proc); 238 MUTILS_API quint32 thread_id( void); 239 MUTILS_API quint32 thread_id( const QProcess * const proc); 242 MUTILS_API bool suspend_process( const QProcess *proc, const bool suspend); 245 MUTILS_API bool setup_timer_resolution( const quint32 &interval = 1); 246 MUTILS_API bool reset_timer_resolution( const quint32 &interval = 1); 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()); 253 MUTILS_API bool check_key_state_esc( void); 256 MUTILS_API void shell_change_notification( void); 259 MUTILS_API QString get_file_path( const int &fd); 262 MUTILS_API bool wow64fsredir_disable(uintptr_t &oldValue); 263 MUTILS_API bool wow64fsredir_revert ( const uintptr_t oldValue); 266 MUTILS_API QString get_envvar( const QString &name); 267 MUTILS_API bool set_envvar( const QString &name, const QString &value); 270 MUTILS_API const QLatin1String &null_device( void); 273 MUTILS_API void check_debugger( void); 276 MUTILS_API void fatal_exit( const wchar_t* const errorMessage); 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. 70 bool isObjectCreated( void); 81 bool addProcessToJob( const QProcess * const process); 92 bool terminateJob( const quint32 &exitCode); 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. 34 template< typename K, typename V> class QHash; 42 #define MUTILS_INTERFACE 2 45 #define MUTILS_BUILD_KEY_HELPER(X,Y) X##" "##Y 46 #define MUTILS_BUILD_KEY MUTILS_BUILD_KEY_HELPER(__DATE__, __TIME__) 50 # ifdef MUTILS_DLL_EXPORT 51 # define MUTILS_API __declspec(dllexport) 53 # ifndef MUTILS_STATIC_LIB 54 # define MUTILS_API __declspec(dllimport) 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! 70 # define MUTILS_DEBUG (0) 71 # if (!defined(NDEBUG)) || (!defined(QT_NO_DEBUG)) || defined(QT_DEBUG) 72 # error Inconsistent DEBUG flags have been detected! 77 #if defined(_MSC_VER) && (!defined(__INTELLISENSE__)) && (!defined(_M_X64)) && defined(_M_IX86_FP) 79 #error We should not enabled SSE or SSE2 in release builds! 84 #define MUTILS_GLUE_NAME_HELPER(X,Y) X##Y 85 #define MUTILS_GLUE_NAME(X,Y) MUTILS_GLUE_NAME_HELPER(X,Y) 87 #define MUTILS_INITIALIZER MUTILS_GLUE_NAME(initialize_d, MUTILS_INTERFACE) 89 #define MUTILS_INITIALIZER MUTILS_GLUE_NAME(initialize_r, MUTILS_INTERFACE) 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)) 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); 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); 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); 207 MUTILS_API bool parity(quint32 value); 218 MUTILS_API bool remove_file( const QString &fileName); 231 MUTILS_API bool remove_directory( const QString &folderPath, const bool &recursive); 253 MUTILS_API QString& trim_left(QString &str); 264 MUTILS_API QString trim_right( const QString &str); 275 MUTILS_API QString trim_left( const QString &str); 299 MUTILS_API QString clean_file_name( const QString &name, const bool &pretty); 312 MUTILS_API QString clean_file_path( const QString &path, const bool &pretty); 326 MUTILS_API bool regexp_parse_int32( const QRegExp ®exp, qint32 &value); 327 MUTILS_API bool regexp_parse_uint32( const QRegExp ®exp, quint32 &value, const size_t &offset); 328 MUTILS_API bool regexp_parse_int32( const QRegExp ®exp, qint32 &value, const size_t &offset); 343 MUTILS_API bool regexp_parse_uint32( const QRegExp ®exp, quint32 *values, const size_t &count); 344 MUTILS_API bool regexp_parse_int32( const QRegExp ®exp, qint32 *values, const size_t &count); 345 MUTILS_API bool regexp_parse_uint32( const QRegExp ®exp, quint32 *values, const size_t &offset, const size_t &count); 346 MUTILS_API bool regexp_parse_int32( const QRegExp ®exp, qint32 *values, const size_t &offset, const size_t &count); 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); 382 #define MUTILS_DELETE(PTR) do { if((PTR)) { delete (PTR); (PTR) = NULL; } } while(0) 386 #define MUTILS_DELETE_ARRAY(PTR) do { if((PTR)) { delete [] (PTR); (PTR) = NULL; } } while(0) 390 #define MUTILS_ZERO_MEMORY(PTR) memset(&(PTR), 0, sizeof((PTR))) 394 #define MUTILS_WCHR(STR) (reinterpret_cast<const wchar_t*>((STR).utf16())) 398 #define MUTILS_UTF8(STR) ((STR).toUtf8().constData()) 402 #define MUTILS_L1STR(STR) ((STR).toLatin1().constData()) 406 #define MUTILS_QSTR(STR) (QString::fromUtf16(reinterpret_cast<const unsigned short*>((STR)))) 410 #define MUTILS_BOOL2STR(X) ((X) ? "1" : "0") 414 #define MUTILS_BOOLIFY(X) (!(!(X))) 418 #define MUTILS_ARR2LEN(X) (sizeof((X)) / sizeof((X)[0])) 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. 34 template< typename K, typename V> class QHash; 42 #define MUTILS_INTERFACE 2 46 # ifdef MUTILS_DLL_EXPORT 47 # define MUTILS_API __declspec(dllexport) 49 # ifndef MUTILS_STATIC_LIB 50 # define MUTILS_API __declspec(dllimport) 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! 66 # define MUTILS_DEBUG (0) 67 # if (!defined(NDEBUG)) || (!defined(QT_NO_DEBUG)) || defined(QT_DEBUG) 68 # error Inconsistent DEBUG flags have been detected! 73 #if defined(_MSC_VER) && (!defined(__INTELLISENSE__)) && (!defined(_M_X64)) && defined(_M_IX86_FP) 75 #error We should not enabled SSE or SSE2 in release builds! 80 #define MUTILS_GLUE_NAME_HELPER(X,Y) X##Y 81 #define MUTILS_GLUE_NAME(X,Y) MUTILS_GLUE_NAME_HELPER(X,Y) 83 #define MUTILS_INITIALIZER MUTILS_GLUE_NAME(initialize_d, MUTILS_INTERFACE) 85 #define MUTILS_INITIALIZER MUTILS_GLUE_NAME(initialize_r, MUTILS_INTERFACE) 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)) 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); 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); 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); 203 MUTILS_API bool parity(quint32 value); 214 MUTILS_API bool remove_file( const QString &fileName); 227 MUTILS_API bool remove_directory( const QString &folderPath, const bool &recursive); 249 MUTILS_API QString& trim_left(QString &str); 260 MUTILS_API QString trim_right( const QString &str); 271 MUTILS_API QString trim_left( const QString &str); 295 MUTILS_API QString clean_file_name( const QString &name, const bool &pretty); 308 MUTILS_API QString clean_file_path( const QString &path, const bool &pretty); 322 MUTILS_API bool regexp_parse_int32( const QRegExp ®exp, qint32 &value); 323 MUTILS_API bool regexp_parse_uint32( const QRegExp ®exp, quint32 &value, const size_t &offset); 324 MUTILS_API bool regexp_parse_int32( const QRegExp ®exp, qint32 &value, const size_t &offset); 339 MUTILS_API bool regexp_parse_uint32( const QRegExp ®exp, quint32 *values, const size_t &count); 340 MUTILS_API bool regexp_parse_int32( const QRegExp ®exp, qint32 *values, const size_t &count); 341 MUTILS_API bool regexp_parse_uint32( const QRegExp ®exp, quint32 *values, const size_t &offset, const size_t &count); 342 MUTILS_API bool regexp_parse_int32( const QRegExp ®exp, qint32 *values, const size_t &offset, const size_t &count); 369 MUTILS_API unsigned int MUTILS_INITIALIZER( const unsigned int interfaceId); 370 static const unsigned int init_flag = MUTILS_INITIALIZER(MUTILS_INTERFACE); 378 #define MUTILS_DELETE(PTR) do { if((PTR)) { delete (PTR); (PTR) = NULL; } } while(0) 382 #define MUTILS_DELETE_ARRAY(PTR) do { if((PTR)) { delete [] (PTR); (PTR) = NULL; } } while(0) 386 #define MUTILS_ZERO_MEMORY(PTR) memset(&(PTR), 0, sizeof((PTR))) 390 #define MUTILS_WCHR(STR) (reinterpret_cast<const wchar_t*>((STR).utf16())) 394 #define MUTILS_UTF8(STR) ((STR).toUtf8().constData()) 398 #define MUTILS_L1STR(STR) ((STR).toLatin1().constData()) 402 #define MUTILS_QSTR(STR) (QString::fromUtf16(reinterpret_cast<const unsigned short*>((STR)))) 406 #define MUTILS_BOOL2STR(X) ((X) ? "1" : "0") 410 #define MUTILS_BOOLIFY(X) (!(!(X))) 414 #define MUTILS_ARR2LEN(X) (sizeof((X)) / sizeof((X)[0])) 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 ®exp, 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())
|