diff --git a/Siv3D/src/Siv3D-Platform/WindowsDesktop/Siv3D/BinaryReader/BinaryReaderDetail.cpp b/Siv3D/src/Siv3D-Platform/WindowsDesktop/Siv3D/BinaryReader/BinaryReaderDetail.cpp index c50ed6f70..4c84a0f70 100644 --- a/Siv3D/src/Siv3D-Platform/WindowsDesktop/Siv3D/BinaryReader/BinaryReaderDetail.cpp +++ b/Siv3D/src/Siv3D-Platform/WindowsDesktop/Siv3D/BinaryReader/BinaryReaderDetail.cpp @@ -246,14 +246,15 @@ namespace s3d { if (not m_file.file.read(static_cast(dst.pointer), readBytes)) { - m_file.pos = m_file.file.tellg(); - if (m_file.file.eof()) { + setPos(previousPos); return readBytes; } LOG_FAIL(U"❌ BinaryReader `{0}`: ReadFile() failed"_fmt(m_info.fullPath)); + + setPos(previousPos); return 0; } } @@ -286,14 +287,15 @@ namespace s3d { if (not m_file.file.read(static_cast(dst.pointer), readBytes)) { - m_file.pos = m_file.file.tellg(); - if (m_file.file.eof()) { + setPos(previousPos); return readBytes; } LOG_FAIL(U"❌ BinaryReader `{0}`: ReadFile() failed"_fmt(m_info.fullPath)); + + setPos(previousPos); return 0; } } diff --git a/Siv3D/src/Siv3D-Platform/macOS_Linux/Siv3D/BinaryReader/BinaryReaderDetail.cpp b/Siv3D/src/Siv3D-Platform/macOS_Linux/Siv3D/BinaryReader/BinaryReaderDetail.cpp index e8ccc5f00..88fb27db4 100644 --- a/Siv3D/src/Siv3D-Platform/macOS_Linux/Siv3D/BinaryReader/BinaryReaderDetail.cpp +++ b/Siv3D/src/Siv3D-Platform/macOS_Linux/Siv3D/BinaryReader/BinaryReaderDetail.cpp @@ -161,14 +161,15 @@ namespace s3d { if (not m_file.file.read(static_cast(dst.pointer), readBytes)) { - m_file.pos = m_file.file.tellg(); - if (m_file.file.eof()) { + setPos(previousPos); return readBytes; } LOG_FAIL(U"❌ BinaryReader `{0}`: ReadFile() failed"_fmt(m_info.fullPath)); + + setPos(previousPos); return 0; } } @@ -192,14 +193,15 @@ namespace s3d { if (not m_file.file.read(static_cast(dst.pointer), readBytes)) { - m_file.pos = m_file.file.tellg(); - if (m_file.file.eof()) { + setPos(previousPos); return readBytes; } LOG_FAIL(U"❌ BinaryReader `{0}`: ReadFile() failed"_fmt(m_info.fullPath)); + + setPos(previousPos); return 0; } }