Fosfat  1.0.0
Data Structures | Typedefs | Enumerations | Functions
fosfat.h File Reference
#include <inttypes.h>

Go to the source code of this file.

Data Structures

struct  fosfat_time_t
 
struct  fosfat_att_t
 
struct  fosfat_file_t
 

Typedefs

typedef struct fosfat_s fosfat_t
 

Enumerations

enum  fosfat_disk_t { FOSFAT_FD , FOSFAT_HD , FOSFAT_AD , FOSFAT_ED }
 

Functions

fosfat_tfosfat_open (const char *dev, fosfat_disk_t disk, unsigned int flag)
 Load a device compatible Smaky FOS. More...
 
void fosfat_close (fosfat_t *fosfat)
 Free the memory and close the device properly. More...
 
void fosfat_logger (int state)
 Change log level (verbosity). More...
 
char * fosfat_diskname (fosfat_t *fosfat)
 Get the disk's name of a specific device. More...
 
fosfat_file_tfosfat_list_dir (fosfat_t *fosfat, const char *location)
 Get file/dir list of a directory in a linked list. More...
 
void fosfat_free_listdir (fosfat_file_t *var)
 Free the memory for an linked list created by fosfat_list_dir(). More...
 
fosfat_disk_t fosfat_type (fosfat_t *fosfat)
 Get the disk type. More...
 
int fosfat_isdir (fosfat_t *fosfat, const char *location)
 Get boolean information on a specific file or folder. More...
 
int fosfat_islink (fosfat_t *fosfat, const char *location)
 Get boolean information on a specific file or folder. More...
 
int fosfat_isvisible (fosfat_t *fosfat, const char *location)
 Get boolean information on a specific file or folder. More...
 
int fosfat_isencoded (fosfat_t *fosfat, const char *location)
 Get boolean information on a specific file or folder. More...
 
int fosfat_isopenexm (fosfat_t *fosfat, const char *location)
 Get boolean information on a specific file or folder. More...
 
fosfat_file_tfosfat_get_stat (fosfat_t *fosfat, const char *location)
 Get some informations on a file or a directory. More...
 
char * fosfat_symlink (fosfat_t *fosfat, const char *location)
 Get the target of a soft-link. More...
 
int fosfat_get_file (fosfat_t *fosfat, const char *src, const char *dst, int output)
 Get a file from a location and put this on the user hard drive. More...
 
uint8_t * fosfat_get_buffer (fosfat_t *fosfat, const char *path, int offset, int size)
 Get a buffer of a file. More...
 

Detailed Description

libfosfat public API header.

Definition in file fosfat.h.

Typedef Documentation

◆ fosfat_t

typedef struct fosfat_s fosfat_t

Fosfat handle on a disk.

Definition at line 1 of file fosfat.h.

Enumeration Type Documentation

◆ fosfat_disk_t

Disk types.

Enumerator
FOSFAT_FD 

Floppy Disk.

FOSFAT_HD 

Hard Disk.

FOSFAT_AD 

Auto Detection.

FOSFAT_ED 

Auto Detection fails.

Definition at line 65 of file fosfat.h.

Function Documentation

◆ fosfat_close()

void fosfat_close ( fosfat_t fosfat)

Free the memory and close the device properly.

Parameters
[in]fosfatdisk handle.

◆ fosfat_diskname()

char* fosfat_diskname ( fosfat_t fosfat)

Get the disk's name of a specific device.

The pointer must be freed when no longer used.

Parameters
[in]fosfatdisk handle.
Returns
NULL if error/null-string or return the name.

◆ fosfat_free_listdir()

void fosfat_free_listdir ( fosfat_file_t var)

Free the memory for an linked list created by fosfat_list_dir().

Parameters
[in]varfirst file of the linked list.

◆ fosfat_get_buffer()

uint8_t* fosfat_get_buffer ( fosfat_t fosfat,
const char *  path,
int  offset,
int  size 
)

Get a buffer of a file.

Useful to get only a part of a file without save anything on the user hard drive. You can get all the data if you prefer. The pointer must be freed when no longer used.

Parameters
[in]fosfatdisk handle.
[in]pathfile where get data.
[in]offsetfrom where (in bytes) in the data.
[in]sizehow many bytes.
Returns
NULL if error or return the buffer.

◆ fosfat_get_file()

int fosfat_get_file ( fosfat_t fosfat,
const char *  src,
const char *  dst,
int  output 
)

Get a file from a location and put this on the user hard drive.

You can't get a directory with this function, you must recursively list the directory with fosfat_list_dir() and use fosfat_get_file() with each file entry.

Parameters
[in]fosfatdisk handle.
[in]srcsource location on the FOS disk.
[in]dstdestination location on the user hard drive.
[in]outputboolean to print copy progression in the terminal.
Returns
a boolean, 0 for error.

◆ fosfat_get_stat()

fosfat_file_t* fosfat_get_stat ( fosfat_t fosfat,
const char *  location 
)

Get some informations on a file or a directory.

File size, attributes, creation date, writing date and use date. Look fosfat_file_t structure for more informations. The pointer must be freed when no longer used.

Parameters
[in]fosfatdisk handle.
[in]locationfile or directory where get informations.
Returns
NULL if error or return the file structure.

◆ fosfat_isdir()

int fosfat_isdir ( fosfat_t fosfat,
const char *  location 
)

Get boolean information on a specific file or folder.

Test if the location is a directory.

Parameters
[in]fosfatdisk handle.
[in]locationfile or directory to test.
Returns
a boolean, 0 for false.

◆ fosfat_isencoded()

int fosfat_isencoded ( fosfat_t fosfat,
const char *  location 
)

Get boolean information on a specific file or folder.

Test if the location is encoded.

Parameters
[in]fosfatdisk handle.
[in]locationfile or directory to test.
Returns
a boolean, 0 for false.

◆ fosfat_islink()

int fosfat_islink ( fosfat_t fosfat,
const char *  location 
)

Get boolean information on a specific file or folder.

Test if the location is a soft-link.

Parameters
[in]fosfatdisk handle.
[in]locationfile or directory to test.
Returns
a boolean, 0 for false.

◆ fosfat_isopenexm()

int fosfat_isopenexm ( fosfat_t fosfat,
const char *  location 
)

Get boolean information on a specific file or folder.

Test if the location is 'open exclusif' and 'multiple'.

Parameters
[in]fosfatdisk handle.
[in]locationfile or directory to test.
Returns
a boolean, 0 for false.

◆ fosfat_isvisible()

int fosfat_isvisible ( fosfat_t fosfat,
const char *  location 
)

Get boolean information on a specific file or folder.

Test if the location is not hidden.

Parameters
[in]fosfatdisk handle.
[in]locationfile or directory to test.
Returns
a boolean, 0 for false.

◆ fosfat_list_dir()

fosfat_file_t* fosfat_list_dir ( fosfat_t fosfat,
const char *  location 
)

Get file/dir list of a directory in a linked list.

When the list is no longer used, fosfat_free_listdir() must always be called to free the memory.

Parameters
[in]fosfatdisk handle.
[in]locationdirectory to list.
Returns
NULL if error or return the first file in the directory.

◆ fosfat_logger()

void fosfat_logger ( int  state)

Change log level (verbosity).

By default, the internal logger is disabled. Use this function to enable or disable the verbosity. The logger is enabled or disabled for all devices loaded.

Parameters
[in]stateboolean, 0 to disable the logger.

◆ fosfat_open()

fosfat_t* fosfat_open ( const char *  dev,
fosfat_disk_t  disk,
unsigned int  flag 
)

Load a device compatible Smaky FOS.

The device can be a file or a disk. But with Window$ currently only device are supported. fosfat_close() must always be called to free the memory and close the device.

Linux : specify the location on /dev/... or on a file Window$ : specify the device with 'a' for diskette, 'c' for the first hard disk, etc,...

Parameters
[in]devdevice or location.
[in]disktype of disk, use FOSFAT_AD for auto-detection.
[in]flaguse F_UNDELETE to load deleted files or 0 for normal.
Returns
NULL if error or return the disk handle.

◆ fosfat_symlink()

char* fosfat_symlink ( fosfat_t fosfat,
const char *  location 
)

Get the target of a soft-link.

If the location is a soft-link, then this function will return the location of the target. The pointer must be freed when no longer used.

Parameters
[in]fosfatdisk handle.
[in]locationsoft-link.
Returns
NULL if error/null-string or return the location.

◆ fosfat_type()

fosfat_disk_t fosfat_type ( fosfat_t fosfat)

Get the disk type.

FOSFAT_FD for floppy disk FOSFAT_HD for hard disk

Parameters
[in]fosfatdisk handle.
Returns
the type.