Added built-time option to make "portable" version.

This commit is contained in:
LoRd_MuldeR 2013-04-17 22:05:45 +02:00
parent e3ac0c3d56
commit 978da1214d
2 changed files with 44 additions and 4 deletions

View File

@ -32,6 +32,12 @@
#define VER_LAMEXP_PATCH 2 #define VER_LAMEXP_PATCH 2
#define VER_LAMEXP_BUILD 1274 #define VER_LAMEXP_BUILD 1274
///////////////////////////////////////////////////////////////////////////////
// LameXP Build Options
///////////////////////////////////////////////////////////////////////////////
#define VER_LAMEXP_PORTABLE_EDITION 0
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Tool versions (minimum expected versions!) // Tool versions (minimum expected versions!)
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -277,6 +277,15 @@ static struct
} }
g_lamexp_os_version; g_lamexp_os_version;
//Portable Mode
static struct
{
bool bInitialized;
bool bPortableModeEnabled;
QReadWriteLock lock;
}
g_lamexp_portable;
//Win32 Theme support //Win32 Theme support
static struct static struct
{ {
@ -1428,10 +1437,34 @@ void lamexp_ipc_read(unsigned int *command, char* message, size_t buffSize)
*/ */
bool lamexp_portable_mode(void) bool lamexp_portable_mode(void)
{ {
QReadLocker readLock(&g_lamexp_portable.lock);
if(g_lamexp_portable.bInitialized)
{
return g_lamexp_portable.bPortableModeEnabled;
}
readLock.unlock();
QWriteLocker writeLock(&g_lamexp_portable.lock);
if(!g_lamexp_portable.bInitialized)
{
if(VER_LAMEXP_PORTABLE_EDITION)
{
qWarning("LameXP portable edition!\n");
g_lamexp_portable.bPortableModeEnabled = true;
}
else
{
QString baseName = QFileInfo(QApplication::applicationFilePath()).completeBaseName(); QString baseName = QFileInfo(QApplication::applicationFilePath()).completeBaseName();
int idx1 = baseName.indexOf("lamexp", 0, Qt::CaseInsensitive); int idx1 = baseName.indexOf("lamexp", 0, Qt::CaseInsensitive);
int idx2 = baseName.lastIndexOf("portable", -1, Qt::CaseInsensitive); int idx2 = baseName.lastIndexOf("portable", -1, Qt::CaseInsensitive);
return (idx1 >= 0) && (idx2 >= 0) && (idx1 < idx2); g_lamexp_portable.bPortableModeEnabled = (idx1 >= 0) && (idx2 >= 0) && (idx1 < idx2);
}
g_lamexp_portable.bInitialized = true;
}
return g_lamexp_portable.bPortableModeEnabled;
} }
/* /*
@ -2401,6 +2434,7 @@ extern "C"
LAMEXP_ZERO_MEMORY(g_lamexp_ipc_ptr); LAMEXP_ZERO_MEMORY(g_lamexp_ipc_ptr);
LAMEXP_ZERO_MEMORY(g_lamexp_os_version); LAMEXP_ZERO_MEMORY(g_lamexp_os_version);
LAMEXP_ZERO_MEMORY(g_lamexp_themes_enabled); LAMEXP_ZERO_MEMORY(g_lamexp_themes_enabled);
LAMEXP_ZERO_MEMORY(g_lamexp_portable);
//Make sure we will pass the check //Make sure we will pass the check
g_lamexp_entry_check_flag = ~g_lamexp_entry_check_flag; g_lamexp_entry_check_flag = ~g_lamexp_entry_check_flag;