I did not see anything serious wrong. But you should use
int fd = open(sFilePath, O_RDONLY | O_BINARY, 0);
to ensure that the file is opened in binary mode, because the default Windows
fmode
is
O_TEXT
.
With binary mode, read should then return
iBytesToRead
while not just before the end of file.