cancel
Showing results for 
Search instead for 
Did you mean: 

Stm32f407 FatFs Long File Name

zbiku11
Associate II
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.
1 REPLY 1
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
Up vote any posts that you find helpful, it shows what's working..