Skip to content

Commit 27a88e6

Browse files
committed
fix #1265
1 parent 28cce16 commit 27a88e6

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

Siv3D/src/Siv3D-Platform/WindowsDesktop/Siv3D/BinaryReader/BinaryReaderDetail.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,15 @@ namespace s3d
246246
{
247247
if (not m_file.file.read(static_cast<char*>(dst.pointer), readBytes))
248248
{
249-
m_file.pos = m_file.file.tellg();
250-
251249
if (m_file.file.eof())
252250
{
251+
setPos(previousPos);
253252
return readBytes;
254253
}
255254

256255
LOG_FAIL(U"❌ BinaryReader `{0}`: ReadFile() failed"_fmt(m_info.fullPath));
256+
257+
setPos(previousPos);
257258
return 0;
258259
}
259260
}
@@ -286,14 +287,15 @@ namespace s3d
286287
{
287288
if (not m_file.file.read(static_cast<char*>(dst.pointer), readBytes))
288289
{
289-
m_file.pos = m_file.file.tellg();
290-
291290
if (m_file.file.eof())
292291
{
292+
setPos(previousPos);
293293
return readBytes;
294294
}
295295

296296
LOG_FAIL(U"❌ BinaryReader `{0}`: ReadFile() failed"_fmt(m_info.fullPath));
297+
298+
setPos(previousPos);
297299
return 0;
298300
}
299301
}

Siv3D/src/Siv3D-Platform/macOS_Linux/Siv3D/BinaryReader/BinaryReaderDetail.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,15 @@ namespace s3d
161161
{
162162
if (not m_file.file.read(static_cast<char*>(dst.pointer), readBytes))
163163
{
164-
m_file.pos = m_file.file.tellg();
165-
166164
if (m_file.file.eof())
167165
{
166+
setPos(previousPos);
168167
return readBytes;
169168
}
170169

171170
LOG_FAIL(U"❌ BinaryReader `{0}`: ReadFile() failed"_fmt(m_info.fullPath));
171+
172+
setPos(previousPos);
172173
return 0;
173174
}
174175
}
@@ -192,14 +193,15 @@ namespace s3d
192193
{
193194
if (not m_file.file.read(static_cast<char*>(dst.pointer), readBytes))
194195
{
195-
m_file.pos = m_file.file.tellg();
196-
197196
if (m_file.file.eof())
198197
{
198+
setPos(previousPos);
199199
return readBytes;
200200
}
201201

202202
LOG_FAIL(U"❌ BinaryReader `{0}`: ReadFile() failed"_fmt(m_info.fullPath));
203+
204+
setPos(previousPos);
203205
return 0;
204206
}
205207
}

0 commit comments

Comments
 (0)