[require c++20] [moved to stduuid]
This commit is contained in:
@@ -119,33 +119,15 @@ auto create_curl() -> CURL * {
|
||||
}
|
||||
|
||||
auto create_uuid_string() -> std::string {
|
||||
#ifdef _WIN32
|
||||
UUID guid{};
|
||||
UuidCreate(&guid);
|
||||
std::random_device random_device;
|
||||
auto seed_data = std::array<int, std::mt19937::state_size>{};
|
||||
std::generate(std::begin(seed_data), std::end(seed_data),
|
||||
std::ref(random_device));
|
||||
std::seed_seq seq(std::begin(seed_data), std::end(seed_data));
|
||||
std::mt19937 generator(seq);
|
||||
uuids::uuid_random_generator gen{generator};
|
||||
|
||||
unsigned char *s;
|
||||
UuidToStringA(&guid, &s);
|
||||
|
||||
std::string ret(reinterpret_cast<char *>(s));
|
||||
RpcStringFreeA(&s);
|
||||
|
||||
return ret;
|
||||
#else
|
||||
#if __linux__
|
||||
uuid guid;
|
||||
guid.make(UUID_MAKE_V4);
|
||||
return guid.string();
|
||||
#else
|
||||
uuid_t guid;
|
||||
uuid_generate_random(guid);
|
||||
|
||||
std::string ret;
|
||||
ret.resize(37);
|
||||
uuid_unparse(guid, &ret[0]);
|
||||
|
||||
return ret.c_str();
|
||||
#endif
|
||||
#endif
|
||||
return uuids::to_string(gen());
|
||||
}
|
||||
|
||||
auto create_volume_label(const provider_type &prov) -> std::string {
|
||||
@@ -220,23 +202,12 @@ auto get_attributes_from_meta(const api_meta_map &meta) -> DWORD {
|
||||
}
|
||||
|
||||
auto get_environment_variable(const std::string &variable) -> std::string {
|
||||
#ifdef _WIN32
|
||||
std::string val;
|
||||
auto sz = ::GetEnvironmentVariable(&variable[0], nullptr, 0);
|
||||
if (sz > 0) {
|
||||
val.resize(sz);
|
||||
::GetEnvironmentVariable(&variable[0], &val[0], sz);
|
||||
}
|
||||
|
||||
return value.c_str();
|
||||
#else
|
||||
static std::mutex mtx{};
|
||||
mutex_lock lock{mtx};
|
||||
|
||||
const auto *val = std::getenv(variable.c_str());
|
||||
auto ret = std::string(val == nullptr ? "" : val);
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
auto get_file_time_now() -> std::uint64_t {
|
||||
|
Reference in New Issue
Block a user