diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-11-22 11:50:55 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-11-22 11:50:55 +0100 |
commit | baf99d32bc58074f10cf194e43963f47fae34c08 (patch) | |
tree | a4e80d11a641054db48c8cb2b075d43f3b399b67 /serialize/world-writer.cpp | |
parent | 2da189ce7435d44a83e37963e79ca0eb927f4e23 (diff) |
a
Diffstat (limited to 'serialize/world-writer.cpp')
-rw-r--r-- | serialize/world-writer.cpp | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/serialize/world-writer.cpp b/serialize/world-writer.cpp index 78ce3ac2..9fb65e3d 100644 --- a/serialize/world-writer.cpp +++ b/serialize/world-writer.cpp @@ -13,6 +13,7 @@ #include "loader/scenery.hpp" #include "src/anim-atlas.hpp" #include "src/light.hpp" +#include "compat/strerror.hpp" #include <concepts> #include <cstring> #include <vector> @@ -624,27 +625,18 @@ void world::serialize(StringView filename) { collect(true); char errbuf[128]; - constexpr auto get_error_string = []<size_t N> (char (&buf)[N]) -> const char* { - buf[0] = '\0'; -#ifndef _WIN32 - (void)::strerror_r(errno, buf, std::size(buf)); -#else - (void)::strerror_s(buf, std::size(buf), errno); -#endif - return buf; - }; fm_assert(filename.flags() & StringViewFlag::NullTerminated); if (Path::exists(filename)) Path::remove(filename); FILE_raii file = ::fopen(filename.data(), "wb"); if (!file) - fm_abort("fopen(\"%s\", \"w\"): %s", filename.data(), get_error_string(errbuf)); + fm_abort("fopen(\"%s\", \"w\"): %s", filename.data(), get_error_string(errbuf).data()); writer_state s{*this}; const auto array = s.serialize_world(); if (auto len = ::fwrite(array.data(), array.size(), 1, file); len != 1) - fm_abort("fwrite: %s", get_error_string(errbuf)); + fm_abort("fwrite: %s", get_error_string(errbuf).data()); if (int ret = ::fflush(file); ret != 0) - fm_abort("fflush: %s", get_error_string(errbuf)); + fm_abort("fflush: %s", get_error_string(errbuf).data()); } } // namespace floormat |