Page 1 of 1

How to use fopen in the extended module?

Posted: Mon Sep 05, 2022 12:37 pm
by Mars_CN
I'm writing my own module, which requires file operations. But when I write file * FP = fopen (file, "R") in the C code, the returned result is null, that is, the file does not exist. Is it because I don't have mount spiffs? But why can micropython itself read it? I use Python to execute OS Listdir () can read all the files in the directory.

Re: How to use fopen in the extended module?

Posted: Tue Sep 06, 2022 2:51 am
by jimmo
As per the message, please open new posts at GitHub discussions. https://github.com/orgs/micropython/discussions

MicroPython does not make the libc file methods available. If you want to access the filesystem you need to do it through MicroPython's VFS layer. See extmod/vfs.h