Mercurial > hg > orthanc
comparison Core/SystemToolbox.cpp @ 2172:84d1d392a9ab
GenerateUuid() not available in sandboxed environments
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 23 Nov 2016 12:06:00 +0100 |
parents | fd5875662670 |
children | 1c42860097fc |
comparison
equal
deleted
inserted
replaced
2171:35febe19e874 | 2172:84d1d392a9ab |
---|---|
57 #include <signal.h> | 57 #include <signal.h> |
58 #include <unistd.h> | 58 #include <unistd.h> |
59 #endif | 59 #endif |
60 | 60 |
61 | 61 |
62 // Inclusions for UUID | |
63 // http://stackoverflow.com/a/1626302 | |
64 | |
65 extern "C" | |
66 { | |
67 #ifdef WIN32 | |
68 # include <rpc.h> | |
69 #else | |
70 # include <uuid/uuid.h> | |
71 #endif | |
72 } | |
73 | |
74 | |
62 #include "Logging.h" | 75 #include "Logging.h" |
63 #include "OrthancException.h" | 76 #include "OrthancException.h" |
64 #include "Toolbox.h" | 77 #include "Toolbox.h" |
65 | 78 |
66 #include <boost/filesystem.hpp> | 79 #include <boost/filesystem.hpp> |
475 | 488 |
476 return fopen(path.c_str(), m); | 489 return fopen(path.c_str(), m); |
477 } | 490 } |
478 | 491 |
479 | 492 |
493 std::string SystemToolbox::GenerateUuid() | |
494 { | |
495 #ifdef WIN32 | |
496 UUID uuid; | |
497 UuidCreate ( &uuid ); | |
498 | |
499 unsigned char * str; | |
500 UuidToStringA ( &uuid, &str ); | |
501 | |
502 std::string s( ( char* ) str ); | |
503 | |
504 RpcStringFreeA ( &str ); | |
505 #else | |
506 uuid_t uuid; | |
507 uuid_generate_random ( uuid ); | |
508 char s[37]; | |
509 uuid_unparse ( uuid, s ); | |
510 #endif | |
511 return s; | |
512 } | |
513 | |
514 | |
480 #if BOOST_HAS_DATE_TIME == 1 | 515 #if BOOST_HAS_DATE_TIME == 1 |
481 std::string SystemToolbox::GetNowIsoString() | 516 std::string SystemToolbox::GetNowIsoString() |
482 { | 517 { |
483 boost::posix_time::ptime now = boost::posix_time::second_clock::local_time(); | 518 boost::posix_time::ptime now = boost::posix_time::second_clock::local_time(); |
484 return boost::posix_time::to_iso_string(now); | 519 return boost::posix_time::to_iso_string(now); |