Skip to content

Commit f7cdece

Browse files
committed
docs: README write to file example; reminder to run file.flush()
1 parent 376035a commit f7cdece

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

README.md

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

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

4254
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)