add SEEK_END

This commit is contained in:
Jorj Bauer 2022-01-07 12:25:16 -05:00
parent 548be14913
commit 7c3afa096c
2 changed files with 17 additions and 3 deletions

View File

@ -205,7 +205,6 @@ int NixFileManager::write(int8_t fd, const void *buf, int nbyte)
}
uint32_t pos = fileSeekPositions[fd];
// open, seek, write, close.
ssize_t rv = 0;
int ffd = ::open(cachedNames[fd], O_WRONLY|O_CREAT, 0644);
@ -279,6 +278,15 @@ int NixFileManager::lseek(int8_t fd, int offset, int whence)
return -1;
return offset;
}
// Other cases not supported yet
if (whence == SEEK_END) {
if (offset==0) {
seekToEnd(fd);
return fileSeekPositions[fd];
}
// Otherwise we don't handle this yet - seeking beyond the current end
}
// Other cases not supported yet
printf("FAILED lseek -- type %d offset %d\n", whence, offset);
exit(1); // this is an error condition we need to find and fix if it happens
return -1;
};

View File

@ -290,7 +290,13 @@ int TeensyFileManager::lseek(int8_t fd, int offset, int whence)
return -1;
return offset;
}
// Other cases not supported yet
if (whence == SEEK_END && offset==0) {
seekToEnd(fd);
return fileSeekPositions[fd];
}
// Other cases not supported yet
Serial.println("ERROR: lseek called in an unsupported form");
return -1;
};