Something like this:
Code: Select all
STATIC mp_obj_t test() {
mp_int_t ret_val;
printf("attempting to create file \"test.txt\"\n");
FILE* file;
file = fopen("test.txt", "w");
if(file == NULL){
printf("file pointer is null\n");
ret_val = 0;
} else {
printf("file pointer OK\n");
fclose(file);
ret_val = 1;
}
return mp_obj_new_int(ret_val);
}
MP_DEFINE_CONST_FUN_OBJ_0(test_obj, test);
Does anyone know what functions I have to use to do this? It also would be nice if I could do other operations, like writing data to a file, reading it, delete it, etc.