📄 filesys.h
字号:
/** \file filesys.h * File system interface, Implemented: FAT16, FAT32. * * */#ifndef FAT_H#define FAT_H#include "buffer.h"#include "board.h"/** Use PSW User Definable Flag to indicate FAT16/32 */#define IS_FAT_32 UDFPublic extern xdata unsigned long fileSize;/** Maximum allowable number of fragments in file */#define MAX_NUMBER_FRAGMENTS 10/** Fragment Table. */xdata extern struct fragmentEntry { unsigned long start; /**< Starting sector of fragment */ unsigned long length; /**< Length of fragment in sectors */} fragment[MAX_NUMBER_FRAGMENTS];/** 8 first characters of current file name */xdata extern char currentFileName[12];/** Start the filing system and initialize all necessary subsystems. Init storage and file system. FAT16 and FAT32 are supported */unsigned char InitFileSystem(); /** Open a file for reading. * Prepares the Filing System to read a data file from the storage. * Files are referred to by their numbers, not file names. This makes the * system generic, not necessarily needing a complex file system such as * FAT. The way to assign numbers to files is implementation dependent. * Returns 0 when ok, error code otherwise. * \param fileNumber number of file, starting from beginning of storage, * to open. * * What this function actually does, is: it starts reading the FAT * records from start of the root directory, traversing through * subdirectories as it encounters them. When the fileNumber'th valid * record is encountered, it sets sectorAddress to point to its * first data sector but doesn't load any sector. fileSize is loaded * with the size in bytes indicated in the FAT record.*/unsigned char OpenFile (unsigned int fileNumber);/** Read a character from current file. * This can be called after calling OpenFile. It is a slow method * for reading character based file data. * fileSize holds the number of characters still left in file to be read, * check for fileSize=0 to detect end-of-file. If FGetChar is called * after the end of file is reached, it does nothing and returns 0. */unsigned char FGetChar();/** Build a fragment table starting from current sector. * Returns number of fragments in song. * This function is used to get fast access to the filesystem when * playing so cluster chain needs not be followed when the song * is playing, that would be too slow with MMC cards without * extra buffer memory for the file allocation tables. * \warning This function is too slow! (several seconds per MP3 file), * todo: write specialized routines for FAT16 and FAT32. */unsigned char BuildFragmentTable(void);/** Search for next free sector. * If freeSector is zero, a new file should be allocated. */ unsigned char ScanForFreeSector();/** Next free cluster number */extern xdata unsigned long freeSector;extern data unsigned char fatSectorsPerCluster;void WriteClusterChain();#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -