Util: Fix VFile.readline

This commit is contained in:
Jeffrey Pfau 2015-02-05 03:18:37 -08:00
parent 8eeaa11256
commit af6ead2c97
1 changed files with 3 additions and 2 deletions

View File

@ -104,12 +104,13 @@ ssize_t _vfdReadline(struct VFile* vf, char* buffer, size_t size) {
size_t bytesRead = 0; size_t bytesRead = 0;
while (bytesRead < size - 1) { while (bytesRead < size - 1) {
size_t newRead = read(vfd->fd, &buffer[bytesRead], 1); size_t newRead = read(vfd->fd, &buffer[bytesRead], 1);
bytesRead += newRead;
if (!newRead || buffer[bytesRead] == '\n') { if (!newRead || buffer[bytesRead] == '\n') {
break; break;
} }
bytesRead += newRead;
} }
return buffer[bytesRead] = '\0'; buffer[bytesRead] = '\0';
return bytesRead;
} }
ssize_t _vfdWrite(struct VFile* vf, const void* buffer, size_t size) { ssize_t _vfdWrite(struct VFile* vf, const void* buffer, size_t size) {