Skip to content

Commit d038599

Browse files
committed
FFileReader::IsEof() doesn't work with text files
Config file didn't read with recent changes in code. - Added appError() for this situation. - Returned to use "binary file" mode for reading configs.
1 parent 6a0a315 commit d038599

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

UmodelTool/UmodelSettings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ void CUmodelSettings::Load()
207207
FString ConfigFile;
208208
SetPathOption(ConfigFile, CONFIG_FILE);
209209

210-
FArchive* Ar = new FFileReader(*ConfigFile, FAO_TextFile|FAO_NoOpenError);
210+
FArchive* Ar = new FFileReader(*ConfigFile, FAO_NoOpenError); // can't use FAO_TextFile because of FFileReader::IsEof will not work fine with it
211211
if (!Ar->IsOpen())
212212
{
213213
delete Ar;

Unreal/UnCoreSerialize.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -729,23 +729,26 @@ int64 FFileReader::GetFileSize64() const
729729
// lazy file size computation
730730
if (FileSize < 0)
731731
{
732-
#if _WIN32
733732
FFileReader* _this = const_cast<FFileReader*>(this);
734-
// don't rewind file back
735-
_this->FilePos = _this->FileSize = _filelengthi64(fileno(f));
736-
_this->SeekPos = 0;
733+
#if _WIN32
734+
_this->FileSize = _filelengthi64(fileno(f));
737735
#else
738736
fseeko64(f, 0, SEEK_END);
739-
FFileReader* _this = const_cast<FFileReader*>(this);
740-
// don't rewind file back
741-
_this->FilePos = _this->FileSize = ftello64(f);
737+
_this->FileSize = ftello64(f);
738+
fseeko64(f, 0, FilePos);
742739
#endif // _WIN32
743740
}
744741
return FileSize;
745742
}
746743

747744
bool FFileReader::IsEof() const
748745
{
746+
if (Options & FAO_TextFile)
747+
{
748+
// We're tracking file position as it returned by our read operations, however "text file" means
749+
// skipping "\r" characters, so position may not match.
750+
appError("FFileReader::IsEof is not suitable for text files (%s)", FullName);
751+
}
749752
return (BufferBytesLeft == 0) && (FilePos == GetFileSize64());
750753
}
751754

umodel

0 Bytes
Binary file not shown.

umodel.exe

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)