add:uuid
This commit is contained in:
parent
a667080d96
commit
f6bc83b0de
@ -56,4 +56,6 @@ if(UNAME_OUT MATCHES "alpine" OR UNAME_OUT MATCHES "Alpine")
|
|||||||
message(STATUS "ofen on musl static link")
|
message(STATUS "ofen on musl static link")
|
||||||
target_link_libraries(ofen -static;-static-libstdc++)
|
target_link_libraries(ofen -static;-static-libstdc++)
|
||||||
endif()
|
endif()
|
||||||
|
else()
|
||||||
|
target_link_libraries(ofen PRIVATE Rpcrt4)
|
||||||
endif()
|
endif()
|
||||||
|
@ -47,6 +47,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
static ofString now_time();
|
static ofString now_time();
|
||||||
static ofString get_file_size(long long bytes);
|
static ofString get_file_size(long long bytes);
|
||||||
|
static ofString get_uuid();
|
||||||
};
|
};
|
||||||
|
|
||||||
class CMutBuffer
|
class CMutBuffer
|
||||||
|
@ -7,6 +7,12 @@
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
// 这里这样写是为了处理头文件排序问题
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <rpcdce.h>
|
||||||
|
#else
|
||||||
|
#include <uuid/uuid.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace ofen {
|
namespace ofen {
|
||||||
void CMutBuffer::push(const char* data, int len)
|
void CMutBuffer::push(const char* data, int len)
|
||||||
@ -117,6 +123,33 @@ ofString OfUtil::get_file_size(long long bytes)
|
|||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ofString OfUtil::get_uuid()
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
UUID uuid;
|
||||||
|
UuidCreate(&uuid);
|
||||||
|
ofChar* pUuid = nullptr;
|
||||||
|
#ifdef UNICODE_OFSTR
|
||||||
|
UuidToStringW(&uuid, (RPC_CSTR*)&pUuid);
|
||||||
|
#else
|
||||||
|
UuidToStringA(&uuid, (RPC_CSTR*)&pUuid);
|
||||||
|
#endif
|
||||||
|
ofString ret(pUuid);
|
||||||
|
#ifdef UNICODE_OFSTR
|
||||||
|
RpcStringFreeW((RPC_CSTR*)&pUuid);
|
||||||
|
#else
|
||||||
|
RpcStringFreeA((RPC_CSTR*)&pUuid);
|
||||||
|
#endif
|
||||||
|
return ret;
|
||||||
|
#else
|
||||||
|
uuid_t uuid;
|
||||||
|
uuid_generate(uuid);
|
||||||
|
char uuid_str[37];
|
||||||
|
uuid_unparse(uuid, uuid_str);
|
||||||
|
return ofString(uuid_str);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
std::string CCodec::u8_to_ansi(const std::string& str)
|
std::string CCodec::u8_to_ansi(const std::string& str)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user