1 /*
2  * This file is part of libbluray
3  * Copyright (C) 2009-2010  Obliter0n
4  * Copyright (C) 2009-2010  John Stebbins
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library. If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef BD_FILESYSTEM_H_
22 #define BD_FILESYSTEM_H_
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 #include <stdint.h>
29 
30 /*
31  * file access
32  */
33 
34 typedef struct bd_file_s BD_FILE_H;
35 struct bd_file_s
36 {
37     void* internal;
38     void    (*close) (BD_FILE_H *file);
39     int64_t (*seek)  (BD_FILE_H *file, int64_t offset, int32_t origin);
40     int64_t (*tell)  (BD_FILE_H *file);
41     int     (*eof)   (BD_FILE_H *file);
42     int64_t (*read)  (BD_FILE_H *file, uint8_t *buf, int64_t size);
43     int64_t (*write) (BD_FILE_H *file, const uint8_t *buf, int64_t size);
44 };
45 
46 /*
47  * directory access
48  */
49 
50 // Our dirent struct only contains the parts we care about.
51 typedef struct
52 {
53     char    d_name[256];
54 } BD_DIRENT;
55 
56 typedef struct bd_dir_s BD_DIR_H;
57 struct bd_dir_s
58 {
59     void* internal;
60     void (*close)(BD_DIR_H *dir);
61     int (*read)(BD_DIR_H *dir, BD_DIRENT *entry);
62 };
63 
64 typedef BD_FILE_H* (*BD_FILE_OPEN)(const char* filename, const char *mode);
65 typedef BD_DIR_H* (*BD_DIR_OPEN) (const char* dirname);
66 
67 /**
68  *
69  *  Register function pointer that will be used to open a file
70  *
71  * @param p function pointer
72  * @return previous function pointer registered
73  */
74 /* deprecated - use bd_open_files() instead */
75 BD_FILE_OPEN bd_register_file(BD_FILE_OPEN p);
76 
77 /**
78  *
79  *  Register function pointer that will be used to open a directory
80  *
81  * @param p function pointer
82  * @return previous function pointer registered
83  */
84 /* deprecated - use bd_open_files() instead */
85 BD_DIR_OPEN bd_register_dir(BD_DIR_OPEN p);
86 
87 #ifdef __cplusplus
88 }
89 #endif
90 
91 #endif /* BD_FILESYSTEM_H_ */
92