comparison Resources/Orthanc/Core/SystemToolbox.cpp @ 208:db70f6c5fa4f

sync
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 11 Apr 2018 16:27:09 +0200
parents e7f90aba3c97
children
comparison
equal deleted inserted replaced
205:886230938339 208:db70f6c5fa4f
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();