aboutsummaryrefslogtreecommitdiff
path: root/src/file_null.c
blob: ac2cfe499873aa57b586db3ecc9ac128169dc860 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
#include <bh/internal/file.h>

/**
 * \defgroup file File IO
 *
 * File input/output API
 * \{
 */

/**
 * Creates new file object with specified \a path to file.
 *
 * \param path  Path to the file
 *
 * \return On success, returns new file object.
 * \return On failure, returns null pointer.
 */
bh_file_t *bh_file_new(const char *path)
{
    (void)path;
    return NULL;
}

/**
 * Initializes the \a file object with specified \a path to file.
 *
 * \param file  Pointer to the file object
 * \param path  Path to the file
 *
 * \return On success, returns zero.
 * \return On failure, returns error code.
 */
int bh_file_init(bh_file_t *file,
                 const char *path)
{
    (void)file;
    (void)path;
    return BH_NO_IMPL;
}

/**
 * Destroyes the \a file object.
 *
 * Before destroying the file object, this function ensures that underlying
 * file was closed.
 *
 * \param file  Pointer to the file object
 */
void bh_file_destroy_base(bh_file_t *file)
{
    (void)file;
}

/**
 * Opens the \a file object for specified \a mode of operation.
 *
 * \param file  Pointer to the file object
 * \param mode  Bitmask determining access mode
 *
 * \return On success, returns zero.
 * \return On failure, returns error code.
 *
 * \warning This function should be used in context of implementing child
 *          io objects (files, sockets, streaming compression, etc).
 */
int bh_file_open_base(bh_file_t *file,
                      int mode)
{
    (void)file;
    (void)mode;
    return BH_NO_IMPL;
}

/**
 * Closes the \a file object.
 *
 * \param file  Pointer to the file object
 *
 * \warning This function should be used in context of implementing child
 *          io objects (files, sockets, streaming compression, etc).
 */
void bh_file_close_base(bh_file_t *file)
{
    (void)file;
}

/**
 * Checks if the \a file is open.
 *
 * \param file  Pointer to the file object
 *
 * \return If file object is open - returns non-zero.
 * \return If file object is closed - returns zero.
 *
 * \warning This function should be used in context of implementing child
 *          io objects (files, sockets, streaming compression, etc).
 */
int bh_file_is_open_base(bh_file_t *file)
{
    (void)file;
    return 0;
}

/**
 * Reads up to \a size amount of bytes from the \a file object into memory
 * buffer pointed by \a data pointer.
 *
 * \param file  Pointer to the file object
 * \param data  Pointer to the memory buffer
 * \param size  Maximum number of bytes to be read
 *
 * \return On success, returns number of bytes successfuly read.
 * \return On failure, returns zero.
 *
 * \note To check for end-of-file or error see bh_io_eof and bh_io_error.
 *
 * \warning This function should be used in context of implementing child
 *          io objects (files, sockets, streaming compression, etc).
 */
size_t bh_file_read_base(bh_file_t *file,
                         char *data,
                         size_t size)
{
    (void)file;
    (void)data;
    (void)size;
    return 0;
}

/**
 * Writes up to \a size amount of bytes to the \a file object from memory
 * buffer pointed by \a data pointer.
 *
 * \param file  Pointer to the file object
 * \param data  Pointer to the memory buffer
 * \param size  Maximum number of bytes to be read
 *
 * \return On success, returns number of bytes successfuly written.
 * \return On failure, returns zero.
 *
 * \note To check for error see bh_io_error.
 *
 * \warning This function should be used in context of implementing child
 *          io objects (files, sockets, streaming compression, etc).
 */
size_t bh_file_write_base(bh_file_t *file,
                          const char *data,
                          size_t size)
{
    (void)file;
    (void)data;
    (void)size;
    return 0;
}

/**
 * Synchronizes the \a file object (if possible).
 *
 * In most cases, this function causes any unwritten/buffered data to be
 * written.
 *
 * \param file  Pointer to the file object
 *
 * \warning This function should be used in context of implementing child
 *          io objects (files, sockets, streaming compression, etc).
 */
void bh_file_flush_base(bh_file_t *file)
{
    (void)file;
}

/**
 * Seeks the \a file object in the specified direction \a dir and \a offset
 * (if possible).
 *
 * \param file      Pointer to the file object
 * \param offset    Number of bytes to seek in specified direciton
 * \param dir       Seeking direction
 *
 * \return On success, returns zero.
 * \return On failure, returns error code.
 *
 * \warning This function should be used in context of implementing child
 *          io objects (files, sockets, streaming compression, etc).
 */
int bh_file_seek_base(bh_file_t *file,
                      bh_off_t off,
                      int dir)
{
    (void)file;
    (void)off;
    (void)dir;
    return BH_NO_IMPL;
}

/**
 * Returns total size of the \a file object (if possible)
 *
 * \param file  Pointer to the file object
 *
 * \return On success, returns total size of the file object.
 * \return On failure, returns -1.
 *
 * \warning This function should be used in context of implementing child
 *          io objects (files, sockets, streaming compression, etc).
 */
bh_off_t bh_file_size_base(bh_file_t *file)
{
    (void)file;
    return -1;
}

/**
 * Returns current position in the \a file object (if possible).
 *
 * \param file  Pointer to the io object
 *
 * \return On success, returns current position in the file object.
 * \return On failure, returns -1.
 *
 * \warning This function should be used in context of implementing child
 *          io objects (files, sockets, streaming compression, etc).
 */
bh_off_t bh_file_tell_base(bh_file_t *file)
{
    (void)file;
    return -1;
}

/**
 * Returns available number of bytes to be read from the \a file object.
 *
 * \param file  Pointer to the file object
 *
 * \return On success, returns number of available bytes to be read.
 * \return On failure, returns zero.
 *
 * \warning This function should be used in context of implementing child
 *          io objects (files, sockets, streaming compression, etc).
 */
bh_off_t bh_file_available_base(bh_file_t *file)
{
    (void)file;
    return 0;
}

/**
 * Clears error of the \a file object.
 *
 * \param file  Pointer to the file object
 *
 * \warning This function should be used in context of implementing child
 *          io objects (files, sockets, streaming compression, etc).
 */
void bh_file_clear_base(bh_file_t *file)
{
    (void)file;
}

/**
 * \}
 */