Fosfat 0.4.0
fosfat.h
Go to the documentation of this file.
1/*
2 * FOS libfosfat: API for Smaky file system
3 * Copyright (C) 2006-2010 Mathieu Schroeter <mathieu.schroeter@gamesover.ch>
4 *
5 * Thanks to Pierre Arnaud for his help and the documentation
6 * And to Epsitec SA for the Smaky computers
7 *
8 * This file is part of Fosfat.
9 *
10 * This library is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 *
23 */
24
25#ifndef FOSFAT_H
26#define FOSFAT_H
27
34#ifdef __cplusplus
35extern "C" {
36#endif /* __cplusplus */
37
38#define FF_STRINGIFY(s) #s
39#define FF_TOSTRING(s) FF_STRINGIFY(s)
40
41#define FF_VERSION_INT(a, b, c) (a << 16 | b << 8 | c)
42#define FF_VERSION_DOT(a, b, c) a ##.## b ##.## c
43#define FF_VERSION(a, b, c) FF_VERSION_DOT(a, b, c)
44
45#define LIBFOSFAT_VERSION_MAJOR 0
46#define LIBFOSFAT_VERSION_MINOR 4
47#define LIBFOSFAT_VERSION_MICRO 0
48
49#define LIBFOSFAT_VERSION_INT FF_VERSION_INT(LIBFOSFAT_VERSION_MAJOR, \
50 LIBFOSFAT_VERSION_MINOR, \
51 LIBFOSFAT_VERSION_MICRO)
52#define LIBFOSFAT_VERSION FF_VERSION(LIBFOSFAT_VERSION_MAJOR, \
53 LIBFOSFAT_VERSION_MINOR, \
54 LIBFOSFAT_VERSION_MICRO)
55#define LIBFOSFAT_VERSION_STR FF_TOSTRING(LIBFOSFAT_VERSION)
56#define LIBFOSFAT_BUILD LIBFOSFAT_VERSION_INT
57
58#include <inttypes.h>
59
60#define FOSFAT_NAMELGT 17
61
62#define F_UNDELETE (1 << 0)
63
71
73typedef struct time_s {
74 short int year;
75 short int month;
76 short int day;
77 short int hour;
78 short int minute;
79 short int second;
81
83typedef struct att_s {
84 int isdir : 1;
85 int isvisible : 1;
86 int isencoded : 1;
87 int islink : 1;
88 int isdel : 1;
90
92typedef struct file_info_s {
93 char name[FOSFAT_NAMELGT];
94 int size;
99 /* Linked list */
100 struct file_info_s *next_file;
102
104typedef struct fosfat_s fosfat_t;
105
106
123fosfat_t *fosfat_open (const char *dev, fosfat_disk_t disk, unsigned int flag);
124
130void fosfat_close (fosfat_t *fosfat);
131
141void fosfat_logger (int state);
142
151char *fosfat_diskname (fosfat_t *fosfat);
152
163fosfat_file_t *fosfat_list_dir (fosfat_t *fosfat, const char *location);
164
171
181int fosfat_isdir (fosfat_t *fosfat, const char *location);
182
192int fosfat_islink (fosfat_t *fosfat, const char *location);
193
203int fosfat_isvisible (fosfat_t *fosfat, const char *location);
204
214int fosfat_isencoded (fosfat_t *fosfat, const char *location);
215
225int fosfat_isopenexm (fosfat_t *fosfat, const char *location);
226
238fosfat_file_t *fosfat_get_stat (fosfat_t *fosfat, const char *location);
239
250char *fosfat_symlink (fosfat_t *fosfat, const char *location);
251
266 const char *src, const char *dst, int output);
267
281uint8_t *fosfat_get_buffer (fosfat_t *fosfat,
282 const char *path, int offset, int size);
283
284#ifdef __cplusplus
285}
286#endif /* __cplusplus */
287
288#endif /* FOSFAT_H */
int fosfat_isdir(fosfat_t *fosfat, const char *location)
Get boolean information on a specific file or folder.
void fosfat_close(fosfat_t *fosfat)
Free the memory and close the device properly.
char * fosfat_symlink(fosfat_t *fosfat, const char *location)
Get the target of a soft-link.
int fosfat_islink(fosfat_t *fosfat, const char *location)
Get boolean information on a specific file or folder.
fosfat_file_t * fosfat_get_stat(fosfat_t *fosfat, const char *location)
Get some informations on a file or a directory.
int fosfat_isvisible(fosfat_t *fosfat, const char *location)
Get boolean information on a specific file or folder.
fosfat_disk_t
Definition fosfat.h:65
@ FOSFAT_AD
Definition fosfat.h:68
@ FOSFAT_HD
Definition fosfat.h:67
@ FOSFAT_FD
Definition fosfat.h:66
@ FOSFAT_ED
Definition fosfat.h:69
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.
char * fosfat_diskname(fosfat_t *fosfat)
Get the disk's name of a specific device.
void fosfat_free_listdir(fosfat_file_t *var)
Free the memory for an linked list created by fosfat_list_dir().
struct fosfat_s fosfat_t
Definition fosfat.h:104
int fosfat_isencoded(fosfat_t *fosfat, const char *location)
Get boolean information on a specific file or folder.
fosfat_file_t * fosfat_list_dir(fosfat_t *fosfat, const char *location)
Get file/dir list of a directory in a linked list.
void fosfat_logger(int state)
Change log level (verbosity).
int fosfat_isopenexm(fosfat_t *fosfat, const char *location)
Get boolean information on a specific file or folder.
uint8_t * fosfat_get_buffer(fosfat_t *fosfat, const char *path, int offset, int size)
Get a buffer of a file.
fosfat_t * fosfat_open(const char *dev, fosfat_disk_t disk, unsigned int flag)
Load a device compatible Smaky FOS.
fosfat_time_t time_r
Definition fosfat.h:98
fosfat_time_t time_c
Definition fosfat.h:96
fosfat_att_t att
Definition fosfat.h:95
fosfat_time_t time_w
Definition fosfat.h:97