?? fat.h
字號:
#ifndef _FAT_H
#define _FAT_H
#include "reader.h"
struct FATBpb
{
unsigned char jumpBoot[3];
unsigned char OEMName[8];
UInt16 BytsPerSec;
unsigned char SecPerClus;
UInt16 RsvdSecCnt;
unsigned char NumFATs;
UInt16 RootEntCnt;
UInt32 TotSec;
unsigned char Media;
UInt16 FATSz;
UInt16 SecPerTrk;
UInt16 NumHeads;
UInt32 HiddSec;
unsigned char DrvNum;
UInt32 VolID;
unsigned char BootSig;
unsigned char VolLable[11];
unsigned char FilSysType[8];
UInt16 ExtFlag;
UInt16 FSVer;
UInt32 RootClus;
UInt16 FSInfo;
UInt16 BkBootSec;
};
struct FATFdt
{
unsigned char Name[11];
unsigned char Attr;
unsigned char NTRes;
unsigned char CrtTimeTenth;
UInt16 CrtTime;
UInt16 CrtDate;
UInt16 LstAccDate;
UInt32 FstClus;
UInt16 WrtTime;
UInt16 WrtDate;
UInt32 FileSize;
unsigned char LongName[256];
};
struct FATDriverMessage
{
UInt16 SecPerClus;
UInt16 NumFATs;
UInt32 Fat1Addr;
UInt32 FATSz;
UInt32 RootAddr;
UInt32 DataAddr;
UInt32 TotSec;
UInt32 MaxClusNum;
UInt32 Capacity;
UInt32 Cluster;
unsigned char *ClusterBuf;
UInt32 fat;
unsigned char FatBuf[512];
};
struct FATDirectoryMessage
{
UInt32 Cluster; //當前訪問到的簇
UInt32 Offset; //當前訪問的fdt的偏移量
UInt32 FatherOffset; //其FDT在父目錄中的偏移量
UInt32 FatherCluster; //其FDT在父目錄中的簇號
UInt32 FatherFstClus; //父目錄的首簇號
struct FATFdt Child; //當前訪問到的目錄的項屬性
struct FATFdt Folder; //本目錄的一些屬性
};
struct FATFileMessage
{
UInt32 FatherFstClus; //父目錄的首簇號
UInt32 FatherOffset; //其FDT在父目錄中的偏移量
UInt32 FatherCluster; //其FDT在父目錄中的簇號
struct FATFdt file; //本文件的一些屬性
UInt32 Cluster; //當前訪問到的簇
UInt32 ptr; //當前訪問到的簇內偏移量
};
extern UInt16 FAT_GetInt16(unsigned char *pBuf);
extern UInt32 FAT_GetInt32(unsigned char *pBuf);
extern void FAT_SetInt16(unsigned char *pBuf,UInt16 value);
extern void FAT_SetInt32(unsigned char *pBuf,UInt32 value);
extern PDriver Fat_OpenDriver(PDisk pDisk,UInt32 PartitionPos);
extern PDirectory Fat_OpenDirectory(PDriver pDriver,UInt32 DirectoryMark);
//功能:打開一個已經存在的文件.將一個目錄id轉換為一個目錄對象.
//入口:分區對象,目錄id.
//出口:新的目錄對象.
extern UInt32 Fat_Create(PDirectory pDirectory);
//功能:在某目錄創建一個新的子目錄
//入口:父目錄標記,子目錄名稱.
//出口:子目錄對象.
extern UInt32 Fat_SearchFirst(PDirectory pDirectory);
//功能:查找某目錄下的第一個子目錄項(不算.. .)
//入口:父目錄對象
//出口:目錄項類型(文件或者子目錄),目錄項標記.0表示沒有任何文件和子目錄
extern UInt32 Fat_SearchNext(PDirectory pDirectory);
//功能:查找某目錄下的下一個子目錄項(不算.. .)
//入口:父目錄對象
//出口:目錄項類型(文件或者子目錄),目錄項標記.0表示已經查到結束.
extern UInt32 Fat_SearchPrev(PDirectory pDirectory);
//功能:查找某目錄下的上一個子目錄項(不算.. .)
//入口:父目錄對象
//出口:目錄項類型(文件或者子目錄),目錄項標記.0表示已經查到第一個.
extern UInt32 Fat_GotoAny(PDirectory pDirectory,UInt32 num);
//功能:查找某目錄下第上一個子目錄項(不算.. .)
//入口:父目錄對象,第幾個目錄項.
//出口:目錄項類型(文件或者子目錄),目錄項標記.0不存在.
extern UInt32 Fat_SearchName(PDirectory pDirectory,unsigned char *FileName);
//功能:查找某目錄下是否存在某目錄項.
//入口:父目錄對象,文件名稱
//出口:目錄項類型(文件或者子目錄),目錄項標記.0不存在.
extern UInt32 Fat_GetFileNum(PDirectory pDirectory);
//功能:查找某目錄下存在多少個文件.
//入口:父目錄對象
//出口:文件個數.
extern UInt32 Fat_GetDirectoryNum(PDirectory pDirectory);
//功能:查找某目錄下存在多少個子目錄.
//入口:父目錄對象
//出口:子目錄個數.
extern UInt32 Fat_GetChildNum(PDirectory pDirectory);
//功能:查找某目錄下存在多少個目錄項(包括文件).
//入口:父目錄對象
//出口:子目錄和文件個數和.
extern void Fat_RenameDirectory(PDirectory pDirectory,unsigned char*FileName);
//功能:重新命名一個目錄
//入口:目錄對象
//出口:無.(今后根據需要添加,比如操作不成功等.所有void都與此同)
extern void Fat_RenameFile(PFile pFile,unsigned char*FileName);
//功能:重新命名一個文件.
//入口:文件對象.
//出口:無
extern void Fat_ModifyDirectoryAttr(PDirectory pDirectory);
//功能:重新命名一個目錄
//入口:目錄對象
//出口:無.(今后根據需要添加,比如操作不成功等.所有void都與此同)
extern void Fat_ModifyFileAttr(PFile pFile);
//功能:重新命名一個文件.
//入口:文件對象.
//出口:無
extern void Fat_DeleteDirectory(PDirectory pDirectory);
//功能:刪除一個目錄
//入口:目錄對象
//出口:無.
extern PFile Fat_OpenFile(PDirectory pDirectory,UInt32 FileMark);
//功能:打開一個已經存在的文件.
//入口:目錄對象,文件標記.
//出口:文件對象.
extern PFile Fat_CreateFile(PDirectory pDirectory,unsigned char *FileName);
//功能:創建一個新文件.
//入口:目錄對象.
//出口:文件對象.
extern signed int Fat_GetChar(PFile pFile);
//功能:從文件中讀取一個字符.
//入口:文件對象(已經存在的文件).
//出口:輸出字符.(0~255 以外就表示文件末尾)
extern void Fat_PutChar(PFile pFile,unsigned char ch);
//功能:將一個字符寫入文件.
//入口:文件對象(新建方式).
//出口:無
extern void Fat_ReadFile(PFile pFile,unsigned char *buf,UInt32 size);
//功能:從文件中讀取一塊數據.
//入口:文件對象(已經存在的文件),數據長度和緩沖區.
//出口:無
extern void Fat_WriteFile(PFile pFile,unsigned char *buf,UInt32 size);
//功能:向文件中寫入一塊數據.
//入口:文件對象(新建方式),數據長度和緩沖區.
//出口:無
extern void Fat_DeleteFile(PFile pFile);
//功能:刪除一個文件.
//入口:文件對象.
//出口:無
extern void Fat_CloseFile(PFile pFile);
//功能:關閉一個文件,釋放文件對象.
//入口:文件對象.
//出口:無
extern void Fat_Seek(PFile pFile,UInt32 pos,U8 mode);
//功能:將文件讀指針定位到某處.
//入口:文件對象,位偏移置,mode:FILE_END,FILE_BEGIN,FILE_CUR.
//出口:無
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -