Fatfs f_unlink()API用法

f_unlink()很简便 不需要先执行打开文件操作 直接调用该接口就行。

代码流程如下:

1查看删除文件前文件大小

2删除文件

3查看删除文件后文件大小


Result = f_open(fp,filename,FA_OPEN_ALWAYS | FA_WRITE|FA_READ);
if(Result != 0)
{
    LOG(LOG_ERROR,"ERROR: CreatFile f_open return = %d \r\n",Result);
}
LOG(LOG_INFO,"INFO: size = %d\r\n",(int)f_size(fp));  
Result = f_close(fp);
if(Result != 0)
{
    LOG(LOG_ERROR,"ERROR: CreatFile f_close return = %d \r\n",Result);
}
f_unlink(filename);
Result = f_open(fp,filename,FA_OPEN_ALWAYS | FA_WRITE|FA_READ);
if(Result != 0)
{
    LOG(LOG_ERROR,"ERROR: CreatFile f_open return = %d \r\n",Result);
}
LOG(LOG_INFO,"INFO: size = %d\r\n",(int)f_size(fp));
Result = f_close(fp);
if(Result != 0)
{
    LOG(LOG_ERROR,"ERROR: CreatFile f_close return = %d \r\n",Result);
}




你可能感兴趣的:(文件系统)