///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
-// Copyright (C) 2004-2017 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2020 LoRd_MuldeR <MuldeR2@GMX.de>
//
// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
+// it under the terms of the GNU GENERAL PUBLIC LICENSE as published by
// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version, but always including the *additional*
-// restrictions defined in the "License.txt" file.
+// (at your option) any later version; always including the non-optional
+// LAMEXP GNU GENERAL PUBLIC LICENSE ADDENDUM. See "License.txt" file!
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include <QStringList>
#include <QFileInfo>
#include <QPair>
+#include <QResource>
+#include <QDir>
//MUtils
#include <MUtils/Global.h>
//UINT_MAX
static const quint32 g_max_uint32 = UINT32_MAX;
+
+//Resource file lock
+static QScopedPointer<LockedFile> g_lamexp_rcc_lock;
+
//Helper Macro
#define MAKE_ENTRY(LOCK_FILE,VER,TAG) \
qMakePair((LOCK_FILE),qMakePair((VER),(TAG)))
}
return g_max_uint32;
}
+
+/*
+* Initialize external resources (RCC file)
+*/
+void lamexp_initialize_resources(void)
+{
+ //Load the external RCC file
+#ifndef QT_NODLL
+ if (g_lamexp_rcc_lock.isNull())
+ {
+ const QFileInfo appPath(QCoreApplication::applicationFilePath());
+ const QString rccPath = QString("%1/%2.rcc").arg(appPath.canonicalPath(), appPath.completeBaseName());
+ try
+ {
+ qDebug("Using resource file:\n%s\n", MUTILS_UTF8(rccPath));
+ g_lamexp_rcc_lock.reset(new LockedFile(rccPath));
+ QResource::registerResource(g_lamexp_rcc_lock->filePath());
+ }
+ catch (std::runtime_error&)
+ {
+ qFatal("Failed to load the resource file:\n%s\n", MUTILS_UTF8(QDir::toNativeSeparators(rccPath)));
+ }
+ }
+#endif //!QT_NODLL
+
+ //Make sure resources are accessible!
+ static const char *const RESOURCES[] = { ":/images/Logo.png", ":/tools/lame.x86-i686.exe", NULL };
+ for (size_t i = 0U; RESOURCES[i]; ++i)
+ {
+ QResource resourceCheck(QString::fromLatin1(RESOURCES[i]));
+ if ((!resourceCheck.isValid()) || (resourceCheck.size() <= 0))
+ {
+ qFatal("Qt resource system initialization has failed:\nResource \"%s\" not found!", RESOURCES[i]);
+ }
+ }
+}