#148080 - DSfriol - Wed Jan 02, 2008 12:49 am
I've compiled this simple program with libfat (the latest from CVS, where statvfs *seems* to work) and run it on my DS Lite with R4 (1Gb microSD):
Unfortunately, subsequent calls to "printFreeDiskSpace" show that space is *not* staying constant, but *decreases*, even if I call "unlink" on the created file.
What is not working, statvfs, unlink or...?
Code: |
... void printFreeDiskSpace() { struct statvfs st; statvfs("/.", &st); iprintf("free space [%ld] Kb",(st.f_bfree*st.f_bsize)/(1024)); } int main(void) { initDs(); fatInitDefault(); for (int i=0;i<4;i++) { iprintf("iteration [%d]\n",i); FILE* myf=fopen("/test.txt","wt"); if (myf==NULL) { iprintf("error opening file\n"); return 1; } for (int j=0;j<(1024*16);j++) { fprintf(myf,"0123456789abcdef"); } fclose(myf); printFreeDiskSpace(); if (unlink("/test.txt")==0) { iprintf("ok\n"); printFreeDiskSpace(); } } return 0; } |
Unfortunately, subsequent calls to "printFreeDiskSpace" show that space is *not* staying constant, but *decreases*, even if I call "unlink" on the created file.
What is not working, statvfs, unlink or...?