Improved lamexp_rand_str() function. Also this function now returns shorter strings (by default), which still should be enough to avoid name clashes.
This commit is contained in:
parent
94c199d849
commit
c8242b494c
@ -1493,17 +1493,16 @@ bool lamexp_portable_mode(void)
|
||||
/*
|
||||
* Get a random string
|
||||
*/
|
||||
QString lamexp_rand_str(void)
|
||||
QString lamexp_rand_str(const bool bLong)
|
||||
{
|
||||
QRegExp regExp("\\{(\\w+)-(\\w+)-(\\w+)-(\\w+)-(\\w+)\\}");
|
||||
QString uuid = QUuid::createUuid().toString();
|
||||
const QUuid uuid = QUuid::createUuid().toString();
|
||||
|
||||
if(regExp.indexIn(uuid) >= 0)
|
||||
{
|
||||
return QString().append(regExp.cap(1)).append(regExp.cap(2)).append(regExp.cap(3)).append(regExp.cap(4)).append(regExp.cap(5));
|
||||
}
|
||||
const unsigned int u1 = uuid.data1;
|
||||
const unsigned int u2 = (((unsigned int)(uuid.data2)) << 16) | ((unsigned int)(uuid.data3));
|
||||
const unsigned int u3 = (((unsigned int)(uuid.data4[0])) << 24) | (((unsigned int)(uuid.data4[1])) << 16) | (((unsigned int)(uuid.data4[2])) << 8) | ((unsigned int)(uuid.data4[3]));
|
||||
const unsigned int u4 = (((unsigned int)(uuid.data4[4])) << 24) | (((unsigned int)(uuid.data4[5])) << 16) | (((unsigned int)(uuid.data4[6])) << 8) | ((unsigned int)(uuid.data4[7]));
|
||||
|
||||
throw "The RegExp didn't match on the UUID string. This shouldn't happen ;-)";
|
||||
return bLong ? QString().sprintf("%08x%08x%08x%08x", u1, u2, u3, u4) : QString().sprintf("%08x%08x", (u1 ^ u2), (u3 ^ u4));
|
||||
}
|
||||
|
||||
|
||||
|
@ -130,7 +130,7 @@ bool lamexp_check_tool(const QString &toolName);
|
||||
const QString lamexp_lookup_tool(const QString &toolName);
|
||||
unsigned int lamexp_tool_version(const QString &toolName, QString *tag = NULL);
|
||||
void lamexp_finalization(void);
|
||||
QString lamexp_rand_str(void);
|
||||
QString lamexp_rand_str(const bool bLong = false);
|
||||
const QString &lamexp_temp_folder2(void);
|
||||
void lamexp_ipc_read(unsigned int *command, char* message, size_t buffSize);
|
||||
void lamexp_ipc_send(unsigned int command, const char* message);
|
||||
|
Loading…
Reference in New Issue
Block a user