Mercurial > hg > orthanc
comparison Core/SystemToolbox.cpp @ 2512:4dcafa8d6633
SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 28 Mar 2018 15:20:50 +0200 |
parents | 2717a8872396 |
children | f790999a250a |
comparison
equal
deleted
inserted
replaced
2511:8a0d3044ef53 | 2512:4dcafa8d6633 |
---|---|
60 #if defined(__OpenBSD__) | 60 #if defined(__OpenBSD__) |
61 # include <sys/sysctl.h> // For "sysctl", "CTL_KERN" and "KERN_PROC_ARGS" | 61 # include <sys/sysctl.h> // For "sysctl", "CTL_KERN" and "KERN_PROC_ARGS" |
62 #endif | 62 #endif |
63 | 63 |
64 | 64 |
65 // Inclusions for UUID | |
66 // http://stackoverflow.com/a/1626302 | |
67 | |
68 extern "C" | |
69 { | |
70 #if defined(_WIN32) | |
71 # include <rpc.h> | |
72 #else | |
73 # include <uuid/uuid.h> | |
74 #endif | |
75 } | |
76 | |
77 | |
78 #include "Logging.h" | 65 #include "Logging.h" |
79 #include "OrthancException.h" | 66 #include "OrthancException.h" |
80 #include "Toolbox.h" | 67 #include "Toolbox.h" |
81 | 68 |
82 #include <boost/filesystem.hpp> | 69 #include <boost/filesystem.hpp> |
537 | 524 |
538 return fopen(path.c_str(), m); | 525 return fopen(path.c_str(), m); |
539 } | 526 } |
540 | 527 |
541 | 528 |
542 std::string SystemToolbox::GenerateUuid() | |
543 { | |
544 #ifdef WIN32 | |
545 UUID uuid; | |
546 UuidCreate ( &uuid ); | |
547 | |
548 unsigned char * str; | |
549 UuidToStringA ( &uuid, &str ); | |
550 | |
551 std::string s( ( char* ) str ); | |
552 | |
553 RpcStringFreeA ( &str ); | |
554 #else | |
555 uuid_t uuid; | |
556 uuid_generate_random ( uuid ); | |
557 char s[37]; | |
558 uuid_unparse ( uuid, s ); | |
559 #endif | |
560 return s; | |
561 } | |
562 | |
563 | |
564 static boost::posix_time::ptime GetNow(bool utc) | 529 static boost::posix_time::ptime GetNow(bool utc) |
565 { | 530 { |
566 if (utc) | 531 if (utc) |
567 { | 532 { |
568 return boost::posix_time::second_clock::universal_time(); | 533 return boost::posix_time::second_clock::universal_time(); |