Use hardware UUID as unique id on Apple
This commit is contained in:
parent
c0eb4fbbd9
commit
1bef2eacc5
1 changed files with 14 additions and 0 deletions
|
@ -35,6 +35,8 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <Iphlpapi.h>
|
#include <Iphlpapi.h>
|
||||||
#pragma comment(lib, "iphlpapi.lib")
|
#pragma comment(lib, "iphlpapi.lib")
|
||||||
|
#elif __APPLE__
|
||||||
|
#import <IOKit/IOKitLib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
@ -265,7 +267,19 @@ static std::string get_unique_id()
|
||||||
}
|
}
|
||||||
free(AdapterInfo);
|
free(AdapterInfo);
|
||||||
#elif __APPLE__
|
#elif __APPLE__
|
||||||
|
constexpr int buf_size = 100;
|
||||||
|
char buf[buf_size] = "";
|
||||||
|
memset(&buf, 0, sizeof(buf));
|
||||||
|
io_registry_entry_t ioRegistryRoot = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/");
|
||||||
|
CFStringRef uuidCf = (CFStringRef)IORegistryEntryCreateCFProperty(ioRegistryRoot, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0);
|
||||||
|
IOObjectRelease(ioRegistryRoot);
|
||||||
|
CFStringGetCString(uuidCf, buf, buf_size, kCFStringEncodingMacRoman);
|
||||||
|
CFRelease(uuidCf);
|
||||||
|
// Now convert the string to std::vector<unsigned char>.
|
||||||
|
for (char* c = buf; *c != 0; ++c)
|
||||||
|
unique.emplace_back((unsigned char)(*c));
|
||||||
#else // Linux/BSD
|
#else // Linux/BSD
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// We should have a unique vector<unsigned char>. Append a long prime to be
|
// We should have a unique vector<unsigned char>. Append a long prime to be
|
||||||
|
|
Loading…
Reference in a new issue