[mw_shl_code=c,true] // Register a work area for logical drive 0
f_mount(0,&fs,1);
res=f_mkdir("0
ATA");//在SD卡里面新建文件夹
// Open source file
res = f_open(&fsrc, "srcfile.dat", FA_OPEN_EXISTING | FA_READ);
if (res) die(res);
// Create destination file
res = f_open(&fdst, "dstfile.dat", FA_CREATE_ALWAYS | FA_WRITE);
if (res) die(res);
// Copy source to destination
for (;;) {
res = f_read(&fsrc, buffer, sizeof(buffer), &br);
if (res || br == 0) break; // error or eof
res = f_write(&fdst, buffer, br, &bw);
if (res || bw < br) break; // error or disk full
}
// Close all files
f_close(&fsrc);
f_close(&fdst);
// Unregister a work area before discard it
f_mount(0, NULL,1);[/mw_shl_code]
[mw_shl_code=c,true]以下是f_mount定义[/mw_shl_code]
[mw_shl_code=c,true]/*-----------------------------------------------------------------------*/
/* Mount/Unmount a Logical Drive */
/*-----------------------------------------------------------------------*/
FRESULT f_mount (
FATFS* fs, /* Pointer to the file system object (NULL:unmount)*/
const TCHAR* path, /* Logical drive number to be mounted/unmounted */
BYTE opt /* 0
o not mount (delayed mount), 1:Mount immediately */
)[/mw_shl_code]
我想实现创建TXT文件,但f_mount
(0,*fs)和
f_mount(0, NULL)总有errors.
查看定义后,发现有
f_mount3个参数。
于是我把f_mount(0,*fs)改成了f_mount(0,&fs,1);
f_mount(0, NULL)改成了f_mount(0, NULL,1);
你们移植时有遇到过此情况?
f_mount(NULL,"0:",1);//卸载
一周热门 更多>