Use BackedStringView

This commit is contained in:
Eelco Dolstra 2024-01-18 15:27:57 +01:00
parent a3cf27ca47
commit 1fe8f54bd3
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) { }