File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3131#include < fstream>
3232#include < string>
3333
34+ #if defined(__APPLE__)
35+ #include < uuid/uuid.h>
36+
37+ #include < array>
38+ #endif
39+
3440namespace paimon {
3541
3642class UUID {
3743 public:
3844 static bool Generate (std::string* output) {
45+ #if defined(__APPLE__)
3946 output->clear ();
40- std::ifstream f (" /proc/sys/kernel/random/uuid" );
41- std::getline (f, /* &*/ *output);
47+ std::array<char , 37 > buffer{};
48+ uuid_t uuid;
49+ uuid_generate_random (uuid);
50+ uuid_unparse_lower (uuid, buffer.data ());
51+ *output = buffer.data ();
4252 if (output->size () == 36 ) {
4353 return true ;
44- } else {
45- output->clear ();
46- return false ;
4754 }
55+ #else
56+ output->clear ();
57+ std::ifstream f (" /proc/sys/kernel/random/uuid" );
58+ if (std::getline (f, /* &*/ *output) && output->size () == 36 ) {
59+ return true ;
60+ }
61+ #endif
62+ output->clear ();
63+ return false ;
4864 }
4965};
5066
You can’t perform that action at this time.
0 commit comments