Writing files works in fatfs.

This commit is contained in:
David Given
2022-08-30 22:51:31 +02:00
parent 9d8adcc511
commit f753929e87
25 changed files with 685 additions and 388 deletions

View File

@@ -128,6 +128,19 @@ uint8_t& Bytes::operator [] (unsigned pos)
return (*_data)[pos];
}
Bytes Bytes::readFromFile(const std::string& filename)
{
Bytes bytes;
ByteWriter bw(bytes);
std::ifstream f(filename);
if (!f)
Error() << fmt::format("cannot open '{}': {}", filename, strerror(errno));
bw += f;
return bytes;
}
Bytes Bytes::slice(unsigned start, unsigned len) const
{
start += _low;