///////////////////////////////////////////////////////////////////////////////
// MuldeR's Utilities for Qt
-// Copyright (C) 2004-2019 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2021 LoRd_MuldeR <MuldeR2@GMX.de>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
}
qWarning("%%TEMP%% directory not found -> trying fallback mode now!");
- static const OS::known_folder_t FOLDER_ID[2] = { OS::FOLDER_LOCALAPPDATA, OS::FOLDER_SYSTROOT_DIR };
+ static const OS::known_folder_t FOLDER_ID[2] = { OS::FOLDER_APPDATA_LOCA, OS::FOLDER_SYSROOT };
for(size_t id = 0; id < 2; id++)
{
const QString &knownFolder = OS::known_folder(FOLDER_ID[id]);
}
//Set up system root directory
- const QString sysRoot = QDir::toNativeSeparators(OS::known_folder(OS::FOLDER_SYSTROOT_DIR));
+ const QString sysRoot = QDir::toNativeSeparators(OS::known_folder(OS::FOLDER_SYSROOT));
if (!sysRoot.isEmpty())
{
for (const char *const *ptr = ENVVAR_NAMES_SYS; *ptr; ++ptr)
}
///////////////////////////////////////////////////////////////////////////////
+// PARENT PATH
+///////////////////////////////////////////////////////////////////////////////
+
+static void remove_trailing_separators(QString &pathStr)
+{
+ while (pathStr.endsWith('/'))
+ {
+ pathStr.chop(1);
+ }
+}
+
+MUTILS_API QString MUtils::parent_path(const QString &path)
+{
+ QString parentPath(QDir::fromNativeSeparators(path));
+ remove_trailing_separators(parentPath);
+ const int pos = parentPath.lastIndexOf(QLatin1Char('/'));
+ if (pos >= 0)
+ {
+ parentPath.truncate(pos);
+ remove_trailing_separators(parentPath);
+ if (parentPath.isEmpty())
+ {
+ return QLatin1String("/");
+ }
+ if ((parentPath.length() == 2) && parentPath.at(0).isLetter() && (parentPath.at(1) == QLatin1Char(':')))
+ {
+ parentPath += QLatin1Char('/');
+ }
+ return parentPath;
+ }
+ return QString();
+}
+
+///////////////////////////////////////////////////////////////////////////////
// REGULAR EXPESSION HELPER
///////////////////////////////////////////////////////////////////////////////
// INITIALIZER
///////////////////////////////////////////////////////////////////////////////
-int MUtils::Internal::MUTILS_INITIALIZER(const unsigned int interfaceId, const bool debugFlag, const char *const buildKey)
+unsigned int MUtils::Internal::MUTILS_INITIALIZER(const unsigned int interfaceId)
{
-#if (!MUTILS_DEBUG)
- if((interfaceId != static_cast<unsigned int>(MUTILS_INTERFACE)) || (debugFlag != static_cast<bool>(MUTILS_DEBUG)) || strncmp(buildKey, MUTILS_BUILD_KEY, 14))
+ if(interfaceId != ((unsigned int)MUTILS_INTERFACE))
{
OS::system_message_err(L"MUtils", L"ERROR: MUtils library initialization has failed!");
for(;;) _exit((int)0xC0000142);
}
-#endif //MUTILS_DEBUG
- volatile int _result = MUTILS_INTERFACE;
+ volatile unsigned int _result = MUTILS_INTERFACE;
return _result;
}