Skip to main content
zbiku11
Associate
June 3, 2013
Question

Stm32f407 FatFs Long File Name

  • June 3, 2013
  • 1 reply
  • 584 views
Posted on June 04, 2013 at 00:34

Hi!

I'm using popular fatfs library to handle my SD card.

Now I have to use longer file name, so Ive decided to use LFN.

With standard file name this code works fine:

char lolek[]=''data1234.kml'';

fresult = f_mount( 0, &fatfs ); //mount sd

fresult = f_open( &plik, (const char*)lolek , FA_OPEN_ALWAYS | FA_WRITE );

But LFN works only like this:

TCHAR* lolek = _T(''asdfasfdas'');

fresult = f_mount( 0, &fatfs ); //mount sd

fresult = f_open( &plik, lolek , FA_OPEN_ALWAYS | FA_WRITE );

How to convert standard char* table to TCHAR* table ?

Its a real big riddle for me.

Regards.
    This topic has been closed for replies.

    1 reply

    Tesla DeLorean
    Guru
    June 4, 2013
    Posted on June 04, 2013 at 02:28

    How about one character at a time using some rudimentary C

    TCHAR tarr[512], *t = tarr;
    char test[] = ''long_filename_test'';
    char *s = test;
    while(*s)
    *t++ = (TCHAR)*s++;
    *t = 0;
    fresult = f_mount( 0, &fatfs);
    fresult = f_open( &plik, tarr, FA_OPEN_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..