Skip to main content
er3481
Associate III
December 14, 2016
Question

fatfs create file in directory

  • December 14, 2016
  • 1 reply
  • 2143 views
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?

    This topic has been closed for replies.

    1 reply

    Tesla DeLorean
    Guru
    December 14, 2016
    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..