fatlib

Fatlib is a C library manipulating DOS floppy images containing FAT filesystem. It compiles under Linux and FreeBSD.

Supported:

Download

Source: fatlib-0.15.tar.gz ()

Note: Not tested well, esp. FAT32.

API

Most functions return -1 or NULL on error and set errno.

Disk image is represented by opaque DRIVE * type returned by an open function and supplied as argument to other functions.

DRIVE *fat_open_virt(struct fat_dops *dops, void *priv, int rw)
DRIVE *fat_open_image(const char *path, int rw)
void fat_drive_close(DRIVE *)

Fat_dops structure contains user's methods (read, write...) providing image abstraction. They operate on series of bytes not organized in sectors, it is expected that a user will reorganize and buffer disk accesses.

Forward slash (/) is a separator in paths (Unix convention). File names use UTF-8.

For file i/o generic FILE * interface is used (stdio.h). It can be obtained by:

FILE *fat_fopen(DRIVE *, const char *path, const char *mode)

If something has been written to a file, it should be explicitly fclosed on exit to ensure that stdio buffers are flushed.

Directory operations use FDIR * pointer (similar to libc's DIR *):

FDIR *fat_opendir(DRIVE *, const char *path)
int fat_readdir(FDIR *, struct fat_dirent *)
void fat_closedir(FDIR *)

See fatlib.h for more...

Tools

With the library come simple utils: fdir, fget and fput. (make tools)

See also