Skip to content

Commit 6ebe113

Browse files
authored
Merge pull request #174 from zpg6/docs/flush-after-write
docs: README write to file example; reminder to run `file.flush()`
2 parents 376035a + 758c6bd commit 6ebe113

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ while !my_file.is_eof() {
3737
}
3838
```
3939

40+
For writing files:
41+
42+
```rust
43+
let my_other_file = root_dir.open_file_in_dir("MY_DATA.CSV", embedded_sdmmc::Mode::ReadWriteCreateOrAppend)?;
44+
my_other_file.write(b"Timestamp,Signal,Value\n")?;
45+
my_other_file.write(b"2025-01-01T00:00:00Z,TEMP,25.0\n")?;
46+
my_other_file.write(b"2025-01-01T00:00:01Z,TEMP,25.1\n")?;
47+
my_other_file.write(b"2025-01-01T00:00:02Z,TEMP,25.2\n")?;
48+
49+
// Don't forget to flush the file so that the directory entry is updated
50+
my_other_file.flush()?;
51+
```
52+
4053
### Open directories and files
4154

4255
By default the `VolumeManager` will initialize with a maximum number of `4` open directories, files and volumes. This can be customized by specifying the `MAX_DIR`, `MAX_FILES` and `MAX_VOLUMES` generic consts of the `VolumeManager`:

0 commit comments

Comments
 (0)