0

I want to know that after using f_mkdir() function I am creating "SENT" folder but in that folder, one more "SENT" file/folder is created which does not have any description.

iFResult = f_stat("/SENT" ,&File_Info);     // Check "SENT" folder is 
// present or not, if not present then create it.    
if(iFResult > FR_OK)
{
    iFResult = f_mkdir("/SENT");    //  Create a new directory 
}

I cannot understand the problem is with my code. Any help is appreciated.

snapshot of "SENT" properties

[fatfs: Generic FAT Filesystem Module]

phuclv
  • 37,963
  • 15
  • 156
  • 475
DEV
  • 19
  • 3
  • What is the value of `iFResult` after both `f_stat` and `f_mkdir`? – peterdn Jan 02 '18 at 14:58
  • After successful completion of this function, it will return zero and not successful it will return non zero value. for more reference:- http://elm-chan.org/fsw/ff/doc/rc.html – DEV Jan 02 '18 at 17:41
  • I know that. My question was what values do they actually return when you run as above, particularly after `f_mkdir`? Also, do other operating systems report `SENT` as being a file, or only Windows? – peterdn Jan 02 '18 at 18:13
  • When SD card is empty, then on the first iteration "f_stat" return "FR_NO_FILE" i.e 4 as it is enum type and "f_mkdir" return the " FR_OK" (0) and on the 2 iterations it "f_stat" return " FR_OK" and it did not when inside the "if " conditions. – DEV Jan 03 '18 at 05:49
  • Hmm, have you tried reading the SD card with another operating system? How did you format the SD card, with Windows or with fsfat? Also, does fsfat itself think that `SKIP` is a directory or a file? – peterdn Jan 03 '18 at 13:34
  • `SENT`, not `SKIP`... – peterdn Jan 03 '18 at 14:13
  • I am formatting with fat32 in windows only and I took the sd card in the ubuntu there I got to know it is file only which have missing data from another file.While debugging I get to know that in renaming the file buffer is missing the data and file got renamed with "SENT" and missing the extension. – DEV Jan 04 '18 at 07:04
  • I had resolved the issue ,thanks for the help – DEV Jan 04 '18 at 07:08
  • thanks for the help – DEV Jan 04 '18 at 07:09

1 Answers1

1

if(iFResult > FR_OK) seems wrong. According to the documentation you must test:

if (iFresult == FR_NO_FILE) {
    // file or subdir does not exist
}
else if (iFresult != FR_OK) {
    // error
}
else // file/subdir exists
Paul Ogilvie
  • 25,048
  • 4
  • 23
  • 41
  • I am not working on windows. I am working on TM4C1294NCPDT microcontroller with this third-party filesystem. I am using reference and sample codes as per the vendor from this given link down. http://elm-chan.org/fsw/ff/00index_e.html – DEV Jan 02 '18 at 17:43
  • Thank for the above solutions! – DEV Jan 04 '18 at 07:02