From 1db40ff99bc679ae56a995d6f5a25b03660e5a93 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Mon, 17 Jul 2017 20:26:35 +0100 Subject: [PATCH] UUID: Implemented Win32 version --- source/common/uuid.cpp | 21 +++++++-------------- source/common/uuid.h | 12 ++++++++---- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/source/common/uuid.cpp b/source/common/uuid.cpp index 1a6ee5a..c808791 100644 --- a/source/common/uuid.cpp +++ b/source/common/uuid.cpp @@ -20,21 +20,16 @@ string GenerateUUID() { - -#if defined(__WIN32__) - -#include - - UUID UUIDData; - UuidCreate(&UUIDData); - wchar_t* UUIDStr = 0; - UuidToString(&UUIDData, (RPC_WSTR*)&UUIDStr); - wxString Result(UUIDStr); - +#if defined(WIN32) + UUID uuidData; + UuidCreate(&uuidData); + wchar_t* uuidStr = 0; + UuidToString(&uuidData, (RPC_WSTR*)&uuidStr); + wstring uuidWStr(uuidStr); + std::string uuidOut(uuidWStr.begin(), uuidWStr.end()); #elif defined(__HAIKU__) #else - #include FILE *uuidhdl = popen("uuidgen", "r"); @@ -51,7 +46,6 @@ string GenerateUUID() } pclose(uuidhdl); - #endif if (uuidOut.back() == '\n'){ @@ -61,5 +55,4 @@ string GenerateUUID() } return uuidOut; - } \ No newline at end of file diff --git a/source/common/uuid.h b/source/common/uuid.h index b39e042..31d8976 100644 --- a/source/common/uuid.h +++ b/source/common/uuid.h @@ -16,13 +16,17 @@ // You should have received a copy of the GNU General Public License along // with Calendar. If not, see -#include +#ifndef COMMON_UUID_H +#define COMMON_UUID_H using namespace std; -#ifndef COMMON_UUID_H -#define COMMON_UUID_H +#include + +#if defined(WIN32) +#include +#endif string GenerateUUID(); -#endif \ No newline at end of file +#endif -- 2.39.2