Use BackedStringView

(cherry picked from commit 1fe8f54bd3)
This commit is contained in:
Eelco Dolstra 2024-01-18 15:27:57 +01:00
parent 8bb4cb0565
commit 91e60868bd
2 changed files with 2 additions and 2 deletions

View File

@ -132,7 +132,7 @@ size_t FdSource::readUnbuffered(char * data, size_t len)
n = ::read(fd, data, len); n = ::read(fd, data, len);
} while (n == -1 && errno == EINTR); } while (n == -1 && errno == EINTR);
if (n == -1) { _good = false; throw SysError("reading from file"); } if (n == -1) { _good = false; throw SysError("reading from file"); }
if (n == 0) { _good = false; throw EndOfFile(endOfFileError); } if (n == 0) { _good = false; throw EndOfFile(std::string(*endOfFileError)); }
read += n; read += n;
return n; return n;
} }

View File

@ -153,7 +153,7 @@ struct FdSource : BufferedSource
{ {
int fd; int fd;
size_t read = 0; size_t read = 0;
std::string endOfFileError{"unexpected end-of-file"}; BackedStringView endOfFileError{"unexpected end-of-file"};
FdSource() : fd(-1) { } FdSource() : fd(-1) { }
FdSource(int fd) : fd(fd) { } FdSource(int fd) : fd(fd) { }