Fosfat 0.4.0
|
00001 /* 00002 * FOS libfosfat: API for Smaky file system 00003 * Copyright (C) 2006-2010 Mathieu Schroeter <mathieu.schroeter@gamesover.ch> 00004 * 00005 * Thanks to Pierre Arnaud for his help and the documentation 00006 * And to Epsitec SA for the Smaky computers 00007 * 00008 * This file is part of Fosfat. 00009 * 00010 * This library is free software: you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation, either version 3 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This library is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public License 00021 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00022 * 00023 */ 00024 00025 #ifndef FOSFAT_H 00026 #define FOSFAT_H 00027 00034 #ifdef __cplusplus 00035 extern "C" { 00036 #endif /* __cplusplus */ 00037 00038 #define FF_STRINGIFY(s) #s 00039 #define FF_TOSTRING(s) FF_STRINGIFY(s) 00040 00041 #define FF_VERSION_INT(a, b, c) (a << 16 | b << 8 | c) 00042 #define FF_VERSION_DOT(a, b, c) a ##.## b ##.## c 00043 #define FF_VERSION(a, b, c) FF_VERSION_DOT(a, b, c) 00044 00045 #define LIBFOSFAT_VERSION_MAJOR 0 00046 #define LIBFOSFAT_VERSION_MINOR 4 00047 #define LIBFOSFAT_VERSION_MICRO 0 00048 00049 #define LIBFOSFAT_VERSION_INT FF_VERSION_INT(LIBFOSFAT_VERSION_MAJOR, \ 00050 LIBFOSFAT_VERSION_MINOR, \ 00051 LIBFOSFAT_VERSION_MICRO) 00052 #define LIBFOSFAT_VERSION FF_VERSION(LIBFOSFAT_VERSION_MAJOR, \ 00053 LIBFOSFAT_VERSION_MINOR, \ 00054 LIBFOSFAT_VERSION_MICRO) 00055 #define LIBFOSFAT_VERSION_STR FF_TOSTRING(LIBFOSFAT_VERSION) 00056 #define LIBFOSFAT_BUILD LIBFOSFAT_VERSION_INT 00057 00058 #include <inttypes.h> 00059 00060 #define FOSFAT_NAMELGT 17 00061 00062 #define F_UNDELETE (1 << 0) 00063 00065 typedef enum disk_type { 00066 FOSFAT_FD, 00067 FOSFAT_HD, 00068 FOSFAT_AD, 00069 FOSFAT_ED 00070 } fosfat_disk_t; 00071 00073 typedef struct time_s { 00074 short int year; 00075 short int month; 00076 short int day; 00077 short int hour; 00078 short int minute; 00079 short int second; 00080 } fosfat_time_t; 00081 00083 typedef struct att_s { 00084 int isdir : 1; 00085 int isvisible : 1; 00086 int isencoded : 1; 00087 int islink : 1; 00088 int isdel : 1; 00089 } fosfat_att_t; 00090 00092 typedef struct file_info_s { 00093 char name[FOSFAT_NAMELGT]; 00094 int size; 00095 fosfat_att_t att; 00096 fosfat_time_t time_c; 00097 fosfat_time_t time_w; 00098 fosfat_time_t time_r; 00099 /* Linked list */ 00100 struct file_info_s *next_file; 00101 } fosfat_file_t; 00102 00104 typedef struct fosfat_s fosfat_t; 00105 00106 00123 fosfat_t *fosfat_open (const char *dev, fosfat_disk_t disk, unsigned int flag); 00124 00130 void fosfat_close (fosfat_t *fosfat); 00131 00141 void fosfat_logger (int state); 00142 00151 char *fosfat_diskname (fosfat_t *fosfat); 00152 00163 fosfat_file_t *fosfat_list_dir (fosfat_t *fosfat, const char *location); 00164 00170 void fosfat_free_listdir (fosfat_file_t *var); 00171 00181 int fosfat_isdir (fosfat_t *fosfat, const char *location); 00182 00192 int fosfat_islink (fosfat_t *fosfat, const char *location); 00193 00203 int fosfat_isvisible (fosfat_t *fosfat, const char *location); 00204 00214 int fosfat_isencoded (fosfat_t *fosfat, const char *location); 00215 00225 int fosfat_isopenexm (fosfat_t *fosfat, const char *location); 00226 00238 fosfat_file_t *fosfat_get_stat (fosfat_t *fosfat, const char *location); 00239 00250 char *fosfat_symlink (fosfat_t *fosfat, const char *location); 00251 00265 int fosfat_get_file (fosfat_t *fosfat, 00266 const char *src, const char *dst, int output); 00267 00281 uint8_t *fosfat_get_buffer (fosfat_t *fosfat, 00282 const char *path, int offset, int size); 00283 00284 #ifdef __cplusplus 00285 } 00286 #endif /* __cplusplus */ 00287 00288 #endif /* FOSFAT_H */