cancel
Showing results for 
Search instead for 
Did you mean: 

fatfs create file in directory

er3481
Senior
Posted on December 14, 2016 at 14:07

Hi,

I am using fatfs sdcard stack, how can i create file in a directory? can i use f_open function for this? In f_open function i just specify the name of the file like this:

f_open(&MyFile, 'STM32.TXT', FA_CREATE_ALWAYS | FA_WRITE)

How can i add the directory path?

1 REPLY 1
Posted on December 14, 2016 at 18:13

You could I suppose RTFM, FatFs is reasonably well documented.

http://elm-chan.org/fsw/ff/en/filename.html

 

http://elm-chan.org/fsw/ff/en/chdir.html

 

http://elm-chan.org/fsw/ff/en/mkdir.html

 

I'm pretty sure it won't create a fully qualified path, you need to make the directory tree before you can put a file there. You'd have to do it one node at a time using f_mkdir()

r_mkdir('/SOMEDIR');

f_open(&MyFile, '/SOMEDIR/SOMEFILE.TXT', FA_CREATE_ALWAYS | FA_WRITE)

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..