STM32+SD卡 利用FATFS文件系统创建文件夹并新建txt文件
2017-11-03 10:05
1346 查看
这几天在移植FATFS文件系统,在移植过程中需要新建文件夹下创建新的cfg文件,查找资料后发现需要用到以下函数:
f_mkdir("0:/2017110223");//新建文件夹,其中2017110223是文件夹名称
f_open(filescr1, "0:2017110223/201711011.txt", FA_OPEN_NEW_COVER);//在新建的文件夹下创建新的txt文本文件
新建完成之后要记得关闭该文件,否则就会出错。
f_res = f_close(filescr1);
在移植FATFS文件系统的时候我们可以用随时查看文件操作函数的返回值,针对这些返回值都有特定的意义,针对这些返回值我们可以很快锁定问题。
typedef enum {
FR_OK = 0,
/* (0) Succeeded */
FR_DISK_ERR,
/* (1) A hard error occurred in the low level disk I/O layer */
FR_INT_ERR,
/* (2) Assertion failed */
FR_NOT_READY,
/* (3) The physical drive cannot work */
FR_NO_FILE,
/* (4) Could not find the file */
FR_NO_PATH,
/* (5) Could not find the path */
FR_INVALID_NAME,
/* (6) The path name format is invalid */
FR_DENIED,
/* (7) Access denied due to prohibited access or directory full */
FR_EXIST,
/* (8) Access denied due to prohibited access */
FR_INVALID_OBJECT,
/* (9) The file/directory object is invalid */
FR_WR
925b
ITE_PROTECTED,
/* (10) The physical drive is write protected */
FR_INVALID_DRIVE,
/* (11) The logical drive number is invalid */
FR_NOT_ENABLED,
/* (12) The volume has no work area */
FR_NO_FILESYSTEM,
/* (13) There is no valid FAT volume */
FR_MKFS_ABORTED,
/* (14) The f_mkfs() aborted due to any parameter error */
FR_TIMEOUT,
/* (15) Could not get a grant to access the volume within defined period */
FR_LOCKED,
/* (16) The operation is rejected according to the file sharing policy */
FR_NOT_ENOUGH_CORE,
/* (17) LFN working buffer could not be allocated */
FR_TOO_MANY_OPEN_FILES,
/* (18) Number of open files > _FS_SHARE */
FR_INVALID_PARAMETER
/* (19) Given parameter is invalid */
} FRESULT;
f_mkdir("0:/2017110223");//新建文件夹,其中2017110223是文件夹名称
f_open(filescr1, "0:2017110223/201711011.txt", FA_OPEN_NEW_COVER);//在新建的文件夹下创建新的txt文本文件
新建完成之后要记得关闭该文件,否则就会出错。
f_res = f_close(filescr1);
在移植FATFS文件系统的时候我们可以用随时查看文件操作函数的返回值,针对这些返回值都有特定的意义,针对这些返回值我们可以很快锁定问题。
typedef enum {
FR_OK = 0,
/* (0) Succeeded */
FR_DISK_ERR,
/* (1) A hard error occurred in the low level disk I/O layer */
FR_INT_ERR,
/* (2) Assertion failed */
FR_NOT_READY,
/* (3) The physical drive cannot work */
FR_NO_FILE,
/* (4) Could not find the file */
FR_NO_PATH,
/* (5) Could not find the path */
FR_INVALID_NAME,
/* (6) The path name format is invalid */
FR_DENIED,
/* (7) Access denied due to prohibited access or directory full */
FR_EXIST,
/* (8) Access denied due to prohibited access */
FR_INVALID_OBJECT,
/* (9) The file/directory object is invalid */
FR_WR
925b
ITE_PROTECTED,
/* (10) The physical drive is write protected */
FR_INVALID_DRIVE,
/* (11) The logical drive number is invalid */
FR_NOT_ENABLED,
/* (12) The volume has no work area */
FR_NO_FILESYSTEM,
/* (13) There is no valid FAT volume */
FR_MKFS_ABORTED,
/* (14) The f_mkfs() aborted due to any parameter error */
FR_TIMEOUT,
/* (15) Could not get a grant to access the volume within defined period */
FR_LOCKED,
/* (16) The operation is rejected according to the file sharing policy */
FR_NOT_ENOUGH_CORE,
/* (17) LFN working buffer could not be allocated */
FR_TOO_MANY_OPEN_FILES,
/* (18) Number of open files > _FS_SHARE */
FR_INVALID_PARAMETER
/* (19) Given parameter is invalid */
} FRESULT;
相关文章推荐
- 安卓系统:在SD卡上新建一个文件file.txt,并将经纬度和时间数据写入
- 为STM32移植FATFS,读取SD卡上FAT12/16/32文件系统
- 利用fatfs文件系统实现了SD卡追加…
- 用FATFS文件系统写SD卡的txt文档的问题
- 用FATFS文件系统写SD卡的txt文档的问题
- 基于SD卡的FatFs文件系统(FatFs移植到STM32)
- 基于STM32的SD卡FATFS文件系统学习笔记
- 第37章 基于SD卡的FatFs文件系统—零死角玩转STM32-F429系列
- 第37章 基于SD卡的FatFs文件系统—零死角玩转STM32-F429系列
- FatFs文件系统创建文件夹,在文件夹里创建文件
- 为STM32移植FATFS,读取SD卡上FAT12/16/32文件系统
- 为STM32移植FATFS,读取SD卡上FAT12/16/32文件系统
- RT-Thread 学习笔记(九)---开启基于SD卡中的 Elm FatFS 文件系统
- STM32的简单的SD卡读写(不带文件系统,SPI方式)
- 创建系统无法删除的文件夹 加密文件
- 基于FATFS文件系统使用SDIO的4线模式在SD卡上写入数据(一)
- Android--在手机SD卡上新建一个自定义文件夹并在新建文件夹目录下新建一个文件
- 利用遍历查找输出文件夹下的txt后缀文件
- STM32学习笔记之fatfs文件系统接口函数使用
- SD卡SPI模式下FatFs与znFat文件系统速度比较