fosfat.h
Go to the documentation of this file.
/*
* FOS libfosfat: API for Smaky file system
* Copyright (C) 2006-2010,2023 Mathieu Schroeter <mathieu@schroetersa.ch>
*
* Thanks to Pierre Arnaud for his help and the documentation
* And to Epsitec SA for the Smaky computers
*
* This file is part of Fosfat.
*
* This library is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef FOSFAT_H
#define FOSFAT_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define FF_STRINGIFY(s) #s
#define FF_TOSTRING(s) FF_STRINGIFY(s)
#define FF_VERSION_INT(a, b, c) (a << 16 | b << 8 | c)
#define FF_VERSION_DOT(a, b, c) a ##.## b ##.## c
#define FF_VERSION(a, b, c) FF_VERSION_DOT(a, b, c)
#define LIBFOSFAT_VERSION_MAJOR 1
#define LIBFOSFAT_VERSION_MINOR 0
#define LIBFOSFAT_VERSION_MICRO 1
#define LIBFOSFAT_VERSION_INT FF_VERSION_INT(LIBFOSFAT_VERSION_MAJOR, \
LIBFOSFAT_VERSION_MINOR, \
LIBFOSFAT_VERSION_MICRO)
#define LIBFOSFAT_VERSION FF_VERSION(LIBFOSFAT_VERSION_MAJOR, \
LIBFOSFAT_VERSION_MINOR, \
LIBFOSFAT_VERSION_MICRO)
#define LIBFOSFAT_VERSION_STR FF_TOSTRING(LIBFOSFAT_VERSION)
#define LIBFOSFAT_BUILD LIBFOSFAT_VERSION_INT
#include <inttypes.h>
#define FOSFAT_NAMELGT 17
#define F_UNDELETE (1 << 0)
typedef enum disk_type {
FOSFAT_FD,
FOSFAT_HD,
FOSFAT_AD,
FOSFAT_ED
} fosfat_disk_t;
typedef struct time_s {
short int year;
short int month;
short int day;
short int hour;
short int minute;
short int second;
} fosfat_time_t;
typedef struct att_s {
int isdir : 1;
int isvisible : 1;
int isencoded : 1;
int islink : 1;
int isdel : 1;
} fosfat_att_t;
typedef struct file_info_s {
char name[FOSFAT_NAMELGT];
int size;
fosfat_att_t att;
fosfat_time_t time_c;
fosfat_time_t time_w;
fosfat_time_t time_r;
/* Linked list */
struct file_info_s *next_file;
} fosfat_file_t;
typedef struct fosfat_s fosfat_t;
fosfat_t *fosfat_open (const char *dev, fosfat_disk_t disk, unsigned int flag);
void fosfat_close (fosfat_t *fosfat);
void fosfat_logger (int state);
char *fosfat_diskname (fosfat_t *fosfat);
fosfat_file_t *fosfat_list_dir (fosfat_t *fosfat, const char *location);
void fosfat_free_listdir (fosfat_file_t *var);
fosfat_disk_t fosfat_type (fosfat_t *fosfat);
int fosfat_isdir (fosfat_t *fosfat, const char *location);
int fosfat_islink (fosfat_t *fosfat, const char *location);
int fosfat_isvisible (fosfat_t *fosfat, const char *location);
int fosfat_isencoded (fosfat_t *fosfat, const char *location);
int fosfat_isopenexm (fosfat_t *fosfat, const char *location);
fosfat_file_t *fosfat_get_stat (fosfat_t *fosfat, const char *location);
char *fosfat_symlink (fosfat_t *fosfat, const char *location);
int fosfat_get_file (fosfat_t *fosfat,
const char *src, const char *dst, int output);
uint8_t *fosfat_get_buffer (fosfat_t *fosfat,
const char *path, int offset, int size);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* FOSFAT_H */
fosfat_isdir
int fosfat_isdir(fosfat_t *fosfat, const char *location)
Get boolean information on a specific file or folder.
fosfat_close
void fosfat_close(fosfat_t *fosfat)
Free the memory and close the device properly.
fosfat_type
fosfat_disk_t fosfat_type(fosfat_t *fosfat)
Get the disk type.
fosfat_symlink
char * fosfat_symlink(fosfat_t *fosfat, const char *location)
Get the target of a soft-link.
fosfat_islink
int fosfat_islink(fosfat_t *fosfat, const char *location)
Get boolean information on a specific file or folder.
fosfat_get_stat
fosfat_file_t * fosfat_get_stat(fosfat_t *fosfat, const char *location)
Get some informations on a file or a directory.
fosfat_isvisible
int fosfat_isvisible(fosfat_t *fosfat, const char *location)
Get boolean information on a specific file or folder.
fosfat_disk_t
fosfat_disk_t
Definition fosfat.h:65
FOSFAT_AD
@ FOSFAT_AD
Definition fosfat.h:68
FOSFAT_HD
@ FOSFAT_HD
Definition fosfat.h:67
FOSFAT_FD
@ FOSFAT_FD
Definition fosfat.h:66
FOSFAT_ED
@ FOSFAT_ED
Definition fosfat.h:69
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.
fosfat_diskname
char * fosfat_diskname(fosfat_t *fosfat)
Get the disk's name of a specific device.
fosfat_free_listdir
void fosfat_free_listdir(fosfat_file_t *var)
Free the memory for an linked list created by fosfat_list_dir().
fosfat_t
struct fosfat_s fosfat_t
Definition fosfat.h:104
fosfat_isencoded
int fosfat_isencoded(fosfat_t *fosfat, const char *location)
Get boolean information on a specific file or folder.
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.
fosfat_logger
void fosfat_logger(int state)
Change log level (verbosity).
fosfat_isopenexm
int fosfat_isopenexm(fosfat_t *fosfat, const char *location)
Get boolean information on a specific file or folder.
fosfat_get_buffer
uint8_t * fosfat_get_buffer(fosfat_t *fosfat, const char *path, int offset, int size)
Get a buffer of a file.
fosfat_open
fosfat_t * fosfat_open(const char *dev, fosfat_disk_t disk, unsigned int flag)
Load a device compatible Smaky FOS.
fosfat_att_t
Definition fosfat.h:83
fosfat_file_t
Definition fosfat.h:92
fosfat_file_t::time_r
fosfat_time_t time_r
Definition fosfat.h:98
fosfat_file_t::size
int size
Definition fosfat.h:94
fosfat_file_t::time_c
fosfat_time_t time_c
Definition fosfat.h:96
fosfat_file_t::att
fosfat_att_t att
Definition fosfat.h:95
fosfat_file_t::time_w
fosfat_time_t time_w
Definition fosfat.h:97
fosfat_time_t
Definition fosfat.h:73