#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <file.h>
#include <ctype.h>
#include "fatfs.h"
#include "private/fatfs_int.h"
#include "version.h"
#include "string_extras.h"
Classes | |
struct | FAT_DIR_int |
This structure is used to keep track of a directory structure used by FAT_readdir(), FAT_opendir(), etc. More... | |
Defines | |
#define | MAX_NUM_DRIVERS 3 |
#define | FAT_OPEN_DEF(X, Y) |
The following compiler gymnastics is due to the fact that the TI file system hooks strip the device name off of the path prior to calling the specified function, so there is no way the support multiple FAT devices using the same functions unless you slip in an argument telling the real functions what device they are using. | |
#define | FAT_RENAME_DEF(X, Y) |
#define | FAT_UNLINK_DEF(X, Y) |
Typedefs | |
typedef int(* | fat_open )(const char *, unsigned int, int) |
typedef int(* | fat_rename )(const char *, const char *) |
typedef int(* | fat_unlink )(const char *) |
Functions | |
int | remove_device (char *name) |
int | RegisterFATDriver (RAWREAD apRawReadFunc, RAWWRITE apRawWriteFunc, GETTIME apGetTimeFunc, tsDevInfo *apRawInfo, char *apDeviceName, void *apDriverData) |
Register a FAT device/driver with BIOS CIO utilities. | |
int | RemoveFATDriver (char *apDeviceName) |
REMOVE a FAT device/driver with BIOS CIO utilities. | |
int | FAT_format (tsDevInfo *apRawInfo, RAWWRITE apRawWriteFunc, char *apFATType, void *apDriverData) |
FORMAT a device with a FAT filesystem. | |
int | FAT_mkdir (const char *apPath) |
Create directory on a FAT FileSystem. | |
int | FAT_rmdir (const char *apPath) |
Remove an empty directory on a FAT FileSystem. | |
FAT_DIR * | FAT_opendir (const char *apDirName) |
Open directory for reading (listing). | |
int | FAT_closedir (FAT_DIR *ahDir) |
Close / Free resources associated with FAT_DIR structure initialized with FAT_opendir(). | |
int | FAT_readdir (FAT_DIR *ahDir, FAT_dirent *apDirent) |
Read next directory entry of FAT directory structure. | |
int | FAT_rewinddir (FAT_DIR *ahDir) |
Resets directory listing pointer to beginning of list for a valid FAT_DIR entry as initalized by FAT_opendir. | |
double | FAT_getdiskfree (const char *apDrive) |
Computes the free space on a device based upon the free cluster count. | |
int | FAT_ioctl (const char *apDevName, int cmd, void *argp) |
IOCTL for FAT filasystem Supported IOCTLs are
| |
Variables | |
tsFATDevData | gpFATDevData [MAX_NUM_DRIVERS] |
int | gnNUMFATDevs = 0 |
fat_open | FAT_OPEN_ARRAY [MAX_NUM_DRIVERS] |
fat_rename | FAT_RENAME_ARRAY [MAX_NUM_DRIVERS] |
fat_unlink | FAT_UNLINK_ARRAY [MAX_NUM_DRIVERS] |
#define MAX_NUM_DRIVERS 3 |
#define FAT_OPEN_DEF | ( | X, | |||
Y | ) |
int X(const char *path, unsigned int flags, int fno) \ { \ return(FAT_open(path, flags, fno, &gpFATDevData[Y])); \ }
The following compiler gymnastics is due to the fact that the TI file system hooks strip the device name off of the path prior to calling the specified function, so there is no way the support multiple FAT devices using the same functions unless you slip in an argument telling the real functions what device they are using.
..
#define FAT_RENAME_DEF | ( | X, | |||
Y | ) |
int X(const char *old_name, const char *new_name) \ { \ return(FAT_rename(old_name, new_name, &gpFATDevData[Y])); \ }
#define FAT_UNLINK_DEF | ( | X, | |||
Y | ) |
int X(const char* name) \ { \ return(FAT_unlink(name, &gpFATDevData[Y])); \ }
typedef int(* fat_open)(const char *, unsigned int, int) |
typedef int(* fat_rename)(const char *, const char *) |
typedef int(* fat_unlink)(const char *) |
int remove_device | ( | char * | name | ) |
int RegisterFATDriver | ( | RAWREAD | apRawReadFunc, | |
RAWWRITE | apRawWriteFunc, | |||
GETTIME | apGetTimeFunc, | |||
tsDevInfo * | apRawInfo, | |||
char * | apDeviceName, | |||
void * | apDriverData | |||
) |
Register a FAT device/driver with BIOS CIO utilities.
This routine will load/interrogate the FAT tables on the provided device and register the device driver with the TI stdio lookup table.
[in] | apRawReadFunc | Pointer to RawRead Function used by Driver. |
[in] | apRawWriteFunc | Pointer to RawWrite function used by Driver. |
[in] | apGetTimeFunc | Pointer to RTC function used by Driver (if no RTC available, should be NULL to use tick timer). |
[in] | apRawInfo | Raw Device Info, required by FAT Driver. |
[in] | apDeviceName | Name of device, e.g. "RAMDISK". Must be less than 32 characters. This name is used to specify a path to fopen() from BIOS, e.g., "RAMDISK:\my\home\directory". |
[in] | apDriverData | Driver Data passed to RawRead and RawWrite Routines. |
int RemoveFATDriver | ( | char * | apDeviceName | ) |
REMOVE a FAT device/driver with BIOS CIO utilities.
This routine will remove a FAT device.
[in] | apDeviceName | Name of device, e.g. "RAMDISK". Must be less than 32 characters. This name is used to specify a path to fopen() from BIOS, e.g., "RAMDISK:\my\home\directory". |
int FAT_format | ( | tsDevInfo * | apRawInfo, | |
RAWWRITE | apRawWriteFunc, | |||
char * | apFATType, | |||
void * | apDriverData | |||
) |
FORMAT a device with a FAT filesystem.
This routine is useful for non-volatile devices requiring a FAT filesystem.
[in] | apRawInfo | Device Info Structure required by FAT formatting logic. |
[in] | apRawWriteFunc | Raw Write routine called during format operation. |
[in] | apFATType | "FAT16" (FAT32 and FAT 12 are currently not supported) |
[in] | apDriverData | device drive info passwd to apRawWriteFunc. |
int FAT_mkdir | ( | const char * | apPath | ) |
Create directory on a FAT FileSystem.
[in] | apPath | Fully qualified path of directory to create |
int FAT_rmdir | ( | const char * | apPath | ) |
Remove an empty directory on a FAT FileSystem.
[in] | apPath | Fully qualified path of directory to create |
FAT_DIR* FAT_opendir | ( | const char * | apDirName | ) |
Open directory for reading (listing).
Use this call in combination with FAT_readdir, FAT_closedir, and FAT_rewinddir in order to gather contents of a specified directory.
[in] | apDirName | Fully qualified path of interest |
int FAT_closedir | ( | FAT_DIR * | ahDir | ) |
Close / Free resources associated with FAT_DIR structure initialized with FAT_opendir().
[in] | ahDir | Pointer to successfully opened FAT_DIR structure |
int FAT_readdir | ( | FAT_DIR * | ahDir, | |
FAT_dirent * | apDirent | |||
) |
Read next directory entry of FAT directory structure.
[in] | ahDir | Pointer to a valid FAT_DIR from FAT_opendir |
[out] | apDirent | Pointer to a valid buffer to populate with listing contents. |
int FAT_rewinddir | ( | FAT_DIR * | ahDir | ) |
Resets directory listing pointer to beginning of list for a valid FAT_DIR entry as initalized by FAT_opendir.
[in] | ahDir | Pointer to a valid FAT_DIR from FAT_opendir |
double FAT_getdiskfree | ( | const char * | apDrive | ) |
Computes the free space on a device based upon the free cluster count.
[in] | apDrive | Path name (including at least the device identifier) of the device to compute free space for. |
int FAT_ioctl | ( | const char * | apDevName, | |
int | cmd, | |||
void * | argp | |||
) |
IOCTL for FAT filasystem Supported IOCTLs are
Value of 1 to disable accesstime on readonly files
[in] | apDevName | - Device name to perform IOCTL on |
[in] | cmd | - IOCTL command to implement |
[in] | argp | - cmd specific data |
tsFATDevData gpFATDevData[MAX_NUM_DRIVERS] |
int gnNUMFATDevs = 0 |
fat_open FAT_OPEN_ARRAY[MAX_NUM_DRIVERS] |
{ FAT_open_0, FAT_open_1, FAT_open_2, }
fat_rename FAT_RENAME_ARRAY[MAX_NUM_DRIVERS] |
{ FAT_rename_0, FAT_rename_1, FAT_rename_2, }
fat_unlink FAT_UNLINK_ARRAY[MAX_NUM_DRIVERS] |
{ FAT_unlink_0, FAT_unlink_1, FAT_unlink_2, }