Did you try the code I gave you? even the simplest sample I gave at the end? please try it. I tried formatting my card more than 100 times while trying to debug this. I and about f_sync, did you notice how in the simplest sample I gave you I call f_close just after checking if the file exists? This should have the same effect ?
Code: Select all
f_open(&file, FILE_PATH, FA_OPEN_ALWAYS | FA_READ | FA_WRITE);
if(f_size(&file) == 0) {
printf("init file for the first time (size == 0)\n");
f_expand(&file, 10000, 1);
}
else {
printf("File opened with success\n");
}
f_close(&file);
So the first time it works and says "init file for first time" then 'file opened with success' while the second time it doesn't work and when you open 2nd file it says 'file opened with success' then 'file opened with success' and the file isn't discoverable on windows.
You guys should at least activate the long file names extension. 8 character name in maj looks like crap
even the Standard C Library I/O with the FILE object is buggy when you check if a file was already existing, and can only have 8 characters names by default.
fopen() in c has the exact same behavior, presumably because it relies on the same filesystem.
https://www.tutorialspoint.com/c_standa ... _fopen.htm
This function is normally stable on linux, and on windows, and on any other you can think of