Skip to content

Commit

Permalink
Improved SDK fileex example.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed Feb 29, 2024
1 parent e07cf41 commit d607675
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions examples/sdk/fileex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ i32 main() {

void create_file() {
File file = File::open(F("/test.txt"), F("w"));

IO::print(F("Writing to file: "));
IO::print(file.name());
IO::print(F("\r\n"));

file.write(F("Hello, world!"));
file.close();
}
Expand All @@ -38,6 +43,10 @@ void read_file() {
File file = File::open(F("/test.txt"), F("r"));
rune contents[file.size()];

IO::print(F("Reading from file: "));
IO::print(file.name());
IO::print(F("\r\n"));

i32 data, idx = 0;
while((data = file.read()) != -1)
contents[idx++] = (rune) data;
Expand Down

0 comments on commit d607675

Please sign in to comment.