Skip to content

Commit

Permalink
return bytes written in file.write
Browse files Browse the repository at this point in the history
  • Loading branch information
newdigate committed Oct 6, 2024
1 parent 21bdbe8 commit f45e3ed
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/LinuxFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,22 @@ size_t LinuxFile::write(uint8_t val) {
}

size_t LinuxFile::write(const uint8_t *buf, size_t size) {
size_t t;
if (!mockFile.is_open()) {
return 0;
}

_size += size;
char * memblock = (char *)buf;
mockFile.write(memblock, size);

return t;

size_t before = mockFile.tellp(); //current pos
if (mockFile.write(memblock, size)) {
//compute the difference
size_t numberOfBytesWritten = (size_t)mockFile.tellp() - before;
return numberOfBytesWritten;
}

return 0;
}

int LinuxFile::read() {
Expand Down

0 comments on commit f45e3ed

Please sign in to comment.