fix: Compiling of time functions on Unix
This commit is contained in:
parent
abac42826c
commit
bcbda85a40
@ -6,7 +6,6 @@
|
||||
#include <hex/api/event.hpp>
|
||||
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <codecvt>
|
||||
#include <locale>
|
||||
#include <string>
|
||||
@ -157,28 +156,28 @@ namespace hex::plugin::builtin {
|
||||
|
||||
#if defined(OS_WINDOWS) && defined(ARCH_64_BIT)
|
||||
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.time32", sizeof(__time32_t), [](auto buffer, auto endian, auto style) {
|
||||
auto endianAdjustedTime = hex::changeEndianess(*reinterpret_cast<__time32_t*>(buffer.data()), endian);
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.time32", sizeof(u32), [](auto buffer, auto endian, auto style) {
|
||||
auto endianAdjustedTime = hex::changeEndianess(*reinterpret_cast<u32*>(buffer.data()), endian);
|
||||
|
||||
struct tm ptm = { 0 };
|
||||
std::string value;
|
||||
if (_localtime32_s(&ptm, &endianAdjustedTime) == 0)
|
||||
value = hex::format("{0:%a, %d.%m.%Y %H:%M:%S}", ptm);
|
||||
else
|
||||
try {
|
||||
value = hex::format("{0:%a, %d.%m.%Y %H:%M:%S}", fmt::localtime(endianAdjustedTime));
|
||||
} catch (fmt::format_error &e) {
|
||||
value = "Invalid";
|
||||
}
|
||||
|
||||
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
||||
});
|
||||
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.time64", sizeof(__time64_t), [](auto buffer, auto endian, auto style) {
|
||||
auto endianAdjustedTime = hex::changeEndianess(*reinterpret_cast<__time64_t*>(buffer.data()), endian);
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.time64", sizeof(u64), [](auto buffer, auto endian, auto style) {
|
||||
auto endianAdjustedTime = hex::changeEndianess(*reinterpret_cast<u64*>(buffer.data()), endian);
|
||||
|
||||
struct tm ptm = { 0 };
|
||||
std::string value;
|
||||
if (_localtime64_s(&ptm, &endianAdjustedTime) == 0)
|
||||
value = hex::format("{0:%a, %d.%m.%Y %H:%M:%S}", ptm);
|
||||
else
|
||||
try {
|
||||
value = hex::format("{0:%a, %d.%m.%Y %H:%M:%S}", fmt::localtime(endianAdjustedTime));
|
||||
} catch (fmt::format_error &e) {
|
||||
value = "Invalid";
|
||||
}
|
||||
|
||||
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
||||
});
|
||||
@ -187,12 +186,13 @@ namespace hex::plugin::builtin {
|
||||
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.time", sizeof(time_t), [](auto buffer, auto endian, auto style) {
|
||||
auto endianAdjustedTime = hex::changeEndianess(*reinterpret_cast<time_t*>(buffer.data()), endian);
|
||||
struct tm *ptm = localtime(&endianAdjustedTime);
|
||||
|
||||
std::string value;
|
||||
if (ptm != nullptr)
|
||||
value = hex::format("{0:%a, %d.%m.%Y %H:%M:%S}", *ptm);
|
||||
else
|
||||
try {
|
||||
value = hex::format("{0:%a, %d.%m.%Y %H:%M:%S}", fmt::localtime(endianAdjustedTime));
|
||||
} catch (fmt::format_error &e) {
|
||||
value = "Invalid";
|
||||
}
|
||||
|
||||
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
||||
});
|
||||
|
@ -148,16 +148,9 @@ namespace hex::plugin::builtin::prv {
|
||||
result.emplace_back("hex.builtin.provider.file.size"_lang, hex::toByteString(this->getActualSize()));
|
||||
|
||||
if (this->m_fileStatsValid) {
|
||||
std::string buffer(0xFF, '\x00');
|
||||
|
||||
if (ctime_s(buffer.data(), buffer.size(), &this->m_fileStats.st_ctime) == 0)
|
||||
result.emplace_back("hex.builtin.provider.file.creation"_lang, buffer);
|
||||
|
||||
if (ctime_s(buffer.data(), buffer.size(), &this->m_fileStats.st_atime) == 0)
|
||||
result.emplace_back("hex.builtin.provider.file.access"_lang, buffer);
|
||||
|
||||
if (ctime_s(buffer.data(), buffer.size(), &this->m_fileStats.st_mtime) == 0)
|
||||
result.emplace_back("hex.builtin.provider.file.modification"_lang, buffer);
|
||||
result.emplace_back("hex.builtin.provider.file.creation"_lang, hex::format("{}", fmt::localtime(this->m_fileStats.st_ctime)));
|
||||
result.emplace_back("hex.builtin.provider.file.access"_lang, hex::format("{}", fmt::localtime(this->m_fileStats.st_atime)));
|
||||
result.emplace_back("hex.builtin.provider.file.modification"_lang, hex::format("{}", fmt::localtime(this->m_fileStats.st_mtime)));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -371,8 +371,8 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.inspector.wide", "Wide Zeichen" },
|
||||
{ "hex.builtin.inspector.utf8", "UTF-8 code point" },
|
||||
{ "hex.builtin.inspector.string", "String" },
|
||||
{ "hex.builtin.inspector.time32", "__time32_t" },
|
||||
{ "hex.builtin.inspector.time64", "__time64_t" },
|
||||
{ "hex.builtin.inspector.time32", "time32_t" },
|
||||
{ "hex.builtin.inspector.time64", "time64_t" },
|
||||
{ "hex.builtin.inspector.time", "time_t" },
|
||||
{ "hex.builtin.inspector.guid", "GUID" },
|
||||
{ "hex.builtin.inspector.rgba8", "RGBA8 Farbe" },
|
||||
|
@ -374,8 +374,8 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.inspector.wide", "Wide Character" },
|
||||
{ "hex.builtin.inspector.utf8", "UTF-8 code point" },
|
||||
{ "hex.builtin.inspector.string", "String" },
|
||||
{ "hex.builtin.inspector.time32", "__time32_t" },
|
||||
{ "hex.builtin.inspector.time64", "__time64_t" },
|
||||
{ "hex.builtin.inspector.time32", "time32_t" },
|
||||
{ "hex.builtin.inspector.time64", "time64_t" },
|
||||
{ "hex.builtin.inspector.time", "time_t" },
|
||||
{ "hex.builtin.inspector.guid", "GUID" },
|
||||
{ "hex.builtin.inspector.rgba8", "RGBA8 color" },
|
||||
|
@ -368,8 +368,8 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.inspector.wide", "Wide Character" },
|
||||
{ "hex.builtin.inspector.utf8", "UTF-8 code point" },
|
||||
{ "hex.builtin.inspector.string", "String" },
|
||||
{ "hex.builtin.inspector.time32", "__time32_t" },
|
||||
{ "hex.builtin.inspector.time64", "__time64_t" },
|
||||
{ "hex.builtin.inspector.time32", "time32_t" },
|
||||
{ "hex.builtin.inspector.time64", "time64_t" },
|
||||
{ "hex.builtin.inspector.time", "time_t" },
|
||||
{ "hex.builtin.inspector.guid", "GUID" },
|
||||
{ "hex.builtin.inspector.rgba8", "Colori RGBA8" },
|
||||
|
@ -369,8 +369,8 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.inspector.wide", "宽字符" },
|
||||
{ "hex.builtin.inspector.utf8", "UTF-8代码点" },
|
||||
{ "hex.builtin.inspector.string", "字符串" },
|
||||
{ "hex.builtin.inspector.time32", "__time32_t" },
|
||||
{ "hex.builtin.inspector.time64", "__time64_t" },
|
||||
{ "hex.builtin.inspector.time32", "time32_t" },
|
||||
{ "hex.builtin.inspector.time64", "time64_t" },
|
||||
{ "hex.builtin.inspector.time", "time_t" },
|
||||
{ "hex.builtin.inspector.guid", "GUID" },
|
||||
{ "hex.builtin.inspector.rgba8", "RGBA8颜色" },
|
||||
|
Loading…
x
Reference in New Issue
Block a user