1. 程式人生 > >STM32+SD卡 利用FATFS檔案系統建立資料夾並新建txt檔案

STM32+SD卡 利用FATFS檔案系統建立資料夾並新建txt檔案

這幾天在移植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_WRITE_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;

相關推薦

STM32+SD 利用FATFS檔案系統建立資料新建txt檔案

這幾天在移植FATFS檔案系統,在移植過程中需要新建資料夾下建立新的cfg檔案,查詢資料後發現需要用到以下函式: f_mkdir("0:/2017110223");//新建資料夾,其中2017110223是資料夾名稱 f_open(filescr1, "0:20171102

cordova檔案系統建立資料與讀寫檔案例項

一、cordova 檔案系統 1. 安裝外掛 cordova 需要安裝外掛才能對對手機檔案系統進行操作 cordova plagin add cordova-plugin-file 2. 需要了解的外掛api 1 . cordova.file.externalRootD

node利用fs模組建立資料寫入檔案

var fs = require("fs") ; var txt = "Hello World"; function write(){ fs.exists(path, function (exists

VB.NET建立資料複製檔案的程式碼

                    '新增記錄時必須給該記錄建立存檔檔案目錄                     Dim sml As String = Me.LinkLabel1.Text                                      

android 建立檔案建立資料、將assets下檔案複製到指定目錄下

1.獲取APP當前目錄路徑: public String getPath(){ File fileDire = getFilesDir();//獲取../data/應用的包名/fil

通過配置檔案批量建立資料

public class Main { public static void main(String[] args) throws Exception { FileInputStream fileInputStream = new FileInputStream("src\\folderList

c++建立資料及其中的檔案

程式碼展示 #include <iostream> #include <direct.h> #include <fstream> #include <io

Android N 無法建立資料解決辦法 & 檢測檔案是否存在

1、設定許可權<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-pe

百度——個人雲端儲存pcs——Android使用百度雲盤(2)——建立資料和上傳檔案

經過驗證,直接使用access_token即可。不用再重新申請了。 遇到的一些小問題: 1.資料夾可以建立多級,比如A/B/C,可以一起建立 2.如果建立失敗,有可能是資料夾命名問題。沒有找到規律。但是好像叫tlist就不行。 3.上傳檔案,比較慢。上傳一般都啟動後臺執行緒

關於IOS 向documents等目錄寫檔案建立資料的問題

這個問題糾結了兩天,和同事兩個人一直在看原始程式碼,並沒有實際的進行程式碼驗證,結果導致問題糾結了好久,後來發現其實就是方法定義的問題,不知道是不是準確,簡單的描述各個方法的功能: 1.建立資料夾:

java檔案操作 之 建立資料路徑和新檔案

一:問題 (1)java 的如果資料夾路徑不存在,先建立; (2)如果檔名 的檔案不存在,先建立再讀寫;存在的話直接追加寫,關鍵字true表示追加 (3)File myPath = new File(toFilePath);   if ( !myPath.exists())

hadoop建立資料及將本地檔案移動到hdfs中

[[email protected] localfiles]# hdfs dfs -mkdir /user [[email protected] localfiles]# hdfs

python 建立資料將圖片下載到新建資料

新建資料夾: import os import requests response = requests.get(url) dirname="test" #建立名為test的資料夾 os.mkdir(dirname)   #此處相當於檔案路徑 test/image.jpg,也就是在t

python操作txt檔案資料教程[3]-python讀取資料中所有txt檔案資料轉為csv檔案

python操作txt檔案中資料教程[3]-python讀取資料夾中所有txt檔案並將資料轉為csv檔案 覺得有用的話,歡迎一起討論相互學習~Follow Me 參考文獻 python操作txt檔案中資料教程[1]-使用python讀寫txt檔案 python操作txt檔案中資料教程[2]-pyth

Windows bat指令碼遍歷資料批量修改檔案字尾

這個需求非常常見,例如批量轉換檔案格式等等,程式碼如下: @echo off ::對變數動態捕獲擴充套件變化 set strpdf=pdf set strtxt=txt SETLOCAL ENABLE

linux下 c語言遞迴遍歷資料下所有檔案和子資料(附上替換文字檔案內容的方法)

#include <stdio.h> #include <sys/dir.h> #include <string> #include <sys/stat.h> //判斷是否為資料夾 bool isDir(const cha

安卓之讀取raw資料下得txt檔案

安卓讀取raw資料夾下得txt檔案 相信老哥們對raw資料夾不陌生: res/raw資料夾下得內容會原封不動得打包進apk中,不會被編譯成二進位制檔案。     還有一點就是res/raw資料夾不可以有目錄結構。 使用:     res/raw下得檔案會被對映到R.JAVA

android檔案快取及SD建立資料失敗解決和bitmap記憶體溢位解決

 1.相關程式碼:    新增許可權: <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:na

SD建立資料、寫入檔案、讀取檔案

    <!-- SD卡內建立資料夾 -->     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>

使用FreeRTOS在SD驅動使用非系統延時導致上電重啟不工作的情況

new i開啟 ask 函數 fault 思想 初始化 font 是否 一、問題描述在一個使用FreeRTOS的工程中,只做了SD卡的驅動,由於RTOS使用了Systick,故非系統延時函數使用的是 DWT中的時鐘周期(CYCCNT)計數功能,但是在SD卡驅動中使用了這個非