From 313fe2bc87908e09c43661d40a71d639d38ac7bc Mon Sep 17 00:00:00 2001 From: Adrian Pop Date: Wed, 25 Feb 2015 21:01:11 +0000 Subject: [PATCH] - use rand instead of uuid to get rid of some dependencies git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@24785 f25d12d1-65f4-0310-ae8a-bbce733d8d8e --- SimulationRuntime/c/util/omc_msvc.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/SimulationRuntime/c/util/omc_msvc.c b/SimulationRuntime/c/util/omc_msvc.c index 9b89a18c810..880fbc0f448 100644 --- a/SimulationRuntime/c/util/omc_msvc.c +++ b/SimulationRuntime/c/util/omc_msvc.c @@ -170,35 +170,20 @@ unsigned int alarm (unsigned int seconds) #include /* for mkdir */ #endif -// Do not free the result -char* _getUUIDStr(void) -{ - char uuidStr[37]; - unsigned char *tmp; - UUID uuid; - if (UuidCreate(&uuid) == RPC_S_OK) - UuidToString(&uuid, &tmp); - tmp[36] = '\0'; - memcpy(uuidStr, strlwr((char*)tmp), 36); - RpcStringFree(&tmp); - return strdup(uuidStr); -} - char *mkdtemp(char *tpl) { int numChars = 0, i, len; char tempDirectory[1024], tmpDir[2048]; - char* uuid = _getUUIDStr(); //extract the temp path numChars = GetTempPath(1024, tempDirectory); sprintf(tmpDir, "%s\\%s", tempDirectory, tpl); len = strlen(tmpDir); for (i = len; i < len - 6; i--) { - tmpDir[i] = uuid[len-i]; + /* generate random numbers between 0..9 for the last 6 chars of the temp name */ + tmpDir[i] = 48 + rand()%9; } mkdir(tmpDir); - free(uuid); return strdup(tmpDir); } #endif