⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filesys.h

📁 一个小型的FAT文件系统,支持FAT12/16和目录
💻 H
字号:


#ifndef	_FILESYS_H
#define	_FILESYS_H

#include	"type.h"

#define	OPEN_RD		0
#define	OPEN_WR		1
#define	OPEN_RDRW	2

#define	SEEK_SET	0
#define	SEEK_CUR	1
#define	SEEK_END	2

#define	FA_READ_ONLY	0x01
#define	FA_HIDDEN		0x02
#define	FA_SYSTEM		0x04
#define	FA_VOLUME		0x08
#define	FA_DIRECTORY	0x10
#define	FA_ARCHIVE		0x20



#define	E_FILE_OK				0
#define	E_FILE_EOF				-1
#define	E_FILE_PARAMETER		-2
#define	E_FILE_RESOURCE			-3
#define	E_FILE_STREAM			-4
#define	E_FILE_DESCRIPTOR		-5
#define	E_FILE_NOT_SUPPORT		-6
#define	E_FILE_DRIVE			-7
#define	E_FILE_PATH				-8
#define	E_FILE_EXIST			-9
//#define	E_FILE_NOT_FOUND		-10
//#define	E_FILE_OPENED			-11
#define	E_FILE_CLOSED			-12
#define	E_FILE_DISK_FULL		-13
#define	E_FILE_NAME				-14
#define	E_FILE_NAME_LEN			-15
#define	E_FILE_PATH_LEN			-16
//#define	E_FILE_DIR_MAX			-17
//#define	E_FILE_NOT_DELETE		-18
#define	E_FILE_NOT_EXECUTE		-19
#define	E_FILE_NOT_READY		-20
#define	E_FILE_FORMAT			-21
#define	E_FILE_ATTRIB			-22
#define	E_FILE_MODE				-23
#define	E_FILE_LOCKED			-24

typedef struct file_info {
	USHORT	year;		/* uodated date */
	UCHAR	month;
	UCHAR	day;
	UCHAR	hour;		/* updated time */
	UCHAR	minute;
	UCHAR	second;
	UCHAR	attrib;		/* attribute */
	ULONG	size;		/* file size */
} FILE_INFO;


typedef struct drive_info {
	USHORT	sectorSize;		/* number of byte per a sector */
	USHORT	sectorPerClu;	/* number of sector per a cluster */
	ULONG	freeClu;		/* number of free cluster */
	ULONG	totalClu;		/* total number of cluster in a drive */
} DRIVE_INFO;

typedef struct file_res {
	UCHAR	use_flag;
	UCHAR	driveNum;
	int		descriptor;
}FFILE;


int fsInit(const char *driveName);
FFILE *fsOpen(const char *path, const char *mode);
int fsClose(FFILE *stream);
int fsRead(void *buf, int size, int count, FFILE *stream);
int fsWrite(const void *buf, int size, int count, FFILE *stream);
int fsGetc(FFILE *stream);
int fsPutc(int c, FFILE *stream);
int fsFlush(FFILE *stream);
int fsGetpos(FFILE *stream, long int *pos);
int fsSetpos(FFILE *stream, const long int *pos);
long fsTell(FFILE *stream);
int fsSeek(FFILE *stream, long offset, int origin);
int fsRemove(const char *path);
int fsRename(const char *oldname, const char *newname);
int fsCwd(char **path);
int fsSetAttr(const char *path, UCHAR attr);
int fsChdir(const char *path);
int fsMkdir(const char *path);
int fsRmdir(const char *path);
int fsGetFirstEntry(const char *path, char *name, FILE_INFO *finfo);
int fsGetNextEntry(char *name, FILE_INFO *finfo);
int fsGetFileInfo(const char *path, FILE_INFO *finfo);
int fsGetDriveInfo(char *driveName, DRIVE_INFO *drvInfo);
int fsExecute(const char *path);



#endif	/* _FILESYS_H */


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -