summaryrefslogtreecommitdiff
path: root/supervisor
diff options
context:
space:
mode:
authorAyan Pahwa <iayanpahwa@gmail.com>2019-11-19 01:59:29 +0530
committerAyan Pahwa <iayanpahwa@gmail.com>2019-11-19 01:59:29 +0530
commita0ef667a1474133b1d6e4c3d74020a68f9ae1671 (patch)
tree95419c800d30428bd969da3fd6201c800d54d3b7 /supervisor
parent9000c88965ea3994d653b25407ef0975e19d4373 (diff)
Supervisor: create code.py file with sample code
Diffstat (limited to 'supervisor')
-rw-r--r--supervisor/shared/filesystem.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/supervisor/shared/filesystem.c b/supervisor/shared/filesystem.c
index c50d7f4ee..225dd8d04 100644
--- a/supervisor/shared/filesystem.c
+++ b/supervisor/shared/filesystem.c
@@ -69,6 +69,18 @@ static void make_empty_file(FATFS *fatfs, const char *path) {
f_close(&fp);
}
+
+static void make_sample_code_file(FATFS *fatfs) {
+ FIL fs;
+ UINT *char_written = 0;
+ const byte buffer[] = "print('Hello World!')";
+
+ //Create or modify existing code.py file
+ f_open(fatfs, &fs, "/code.py", FA_WRITE | FA_CREATE_ALWAYS);
+ f_write(&fs, buffer, sizeof(buffer), char_written);
+ f_close(&fs);
+}
+
// we don't make this function static because it needs a lot of stack and we
// want it to be executed without using stack within main() function
void filesystem_init(bool create_allowed, bool force_create) {
@@ -98,6 +110,8 @@ void filesystem_init(bool create_allowed, bool force_create) {
make_empty_file(&vfs_fat->fatfs, "/.metadata_never_index");
make_empty_file(&vfs_fat->fatfs, "/.Trashes");
make_empty_file(&vfs_fat->fatfs, "/.fseventsd/no_log");
+ // make a sample code.py file
+ make_sample_code_file(&vfs_fat->fatfs);
// create empty lib directory
f_mkdir(&vfs_fat->fatfs, "/lib");