Skip to content

Commit 37b33c1

Browse files
committed
fix: don't treat EOF as a failure in getFileText
The function was failing on `!file.good()` which includes the `eof()` case, so an empty file caused a failure. Test for "fail() but not just because we hit EOF", instead.
1 parent 9bbbefa commit 37b33c1

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/lib/Support/Path.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ getFileText(
206206
std::istreambuf_iterator<char> it(file);
207207
std::istreambuf_iterator<char> const end;
208208
std::string text(it, end);
209-
if(! file.good())
209+
if(file.fail() && ! file.eof())
210210
return Unexpected(formatError("getFileText(\"{}\") returned \"{}\"",
211211
pathName, std::error_code(errno, std::generic_category())));
212212
return text;

0 commit comments

Comments
 (0)