Kodi Development 19.0
for Binary and Script based Add-Ons
filesystem.h
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#ifndef C_API_FILESYSTEM_H
10#define C_API_FILESYSTEM_H
11
12#include <stdbool.h>
13#include <stdint.h>
14#include <time.h>
15
16#ifdef _WIN32 // windows
17#ifndef _SSIZE_T_DEFINED
18typedef intptr_t ssize_t;
19#define _SSIZE_T_DEFINED
20#endif // !_SSIZE_T_DEFINED
21
22// Prevent conflicts with Windows macros where have this names.
23#ifdef CreateDirectory
24#undef CreateDirectory
25#endif // CreateDirectory
26#ifdef DeleteFile
27#undef DeleteFile
28#endif // DeleteFile
29#ifdef RemoveDirectory
30#undef RemoveDirectory
31#endif // RemoveDirectory
32#endif // _WIN32
33
34#ifdef TARGET_POSIX // Linux, Mac, FreeBSD
35#include <sys/types.h>
36#endif // TARGET_POSIX
37
38#ifdef __cplusplus
39extern "C"
40{
41#endif /* __cplusplus */
42
43 //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
44 // "C" Definitions, structures and enumerators of filesystem
45 //{{{
46
47 //============================================================================
56 typedef enum OpenFileFlags
57 {
62
67
71
75
79
84
89
93
96 ADDON_READ_REOPEN = 0x100
99 //----------------------------------------------------------------------------
100
101 //============================================================================
108 typedef enum CURLOptiontype
109 {
112
133
136
141 //----------------------------------------------------------------------------
142
143 //============================================================================
152 typedef enum FilePropertyTypes
153 {
168 //----------------------------------------------------------------------------
169
170 //}}}
171
172 //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
173 // "C" Internal interface tables for intercommunications between addon and kodi
174 //{{{
175
177 {
178 void* handle;
179
180 char* (*get_value)(void* kodiBase, void* handle, const char* param);
181 char** (*get_values)(void* kodiBase, void* handle, const char* param, int* length);
182 char* (*get_header)(void* kodiBase, void* handle);
183 char* (*get_mime_type)(void* kodiBase, void* handle);
184 char* (*get_charset)(void* kodiBase, void* handle);
185 char* (*get_proto_line)(void* kodiBase, void* handle);
186 };
187
189 {
191 uint32_t deviceId;
193 uint64_t size;
209 bool isFifo;
217 };
218
220 {
221 uint64_t forward;
222 unsigned int maxrate;
223 unsigned int currate;
224 bool lowspeed;
225 };
226
228 {
229 char* name;
230 char* val;
231 };
232
234 {
235 char* label;
236 char* title;
237 char* path;
238 unsigned int num_props;
240 time_t date_time;
241 bool folder;
242 uint64_t size;
243 };
244
246 {
247 bool (*can_open_directory)(void* kodiBase, const char* url);
248 bool (*create_directory)(void* kodiBase, const char* path);
249 bool (*remove_directory)(void* kodiBase, const char* path);
250 bool (*directory_exists)(void* kodiBase, const char* path);
251 bool (*get_directory)(void* kodiBase,
252 const char* path,
253 const char* mask,
254 struct VFSDirEntry** items,
255 unsigned int* num_items);
256 void (*free_directory)(void* kodiBase, struct VFSDirEntry* items, unsigned int num_items);
257
258 bool (*file_exists)(void* kodiBase, const char* filename, bool useCache);
259 bool (*stat_file)(void* kodiBase, const char* filename, struct STAT_STRUCTURE* buffer);
260 bool (*delete_file)(void* kodiBase, const char* filename);
261 bool (*rename_file)(void* kodiBase, const char* filename, const char* newFileName);
262 bool (*copy_file)(void* kodiBase, const char* filename, const char* dest);
263
264 char* (*get_file_md5)(void* kodiBase, const char* filename);
265 char* (*get_cache_thumb_name)(void* kodiBase, const char* filename);
266 char* (*make_legal_filename)(void* kodiBase, const char* filename);
267 char* (*make_legal_path)(void* kodiBase, const char* path);
268 char* (*translate_special_protocol)(void* kodiBase, const char* strSource);
269 bool (*is_internet_stream)(void* kodiBase, const char* path, bool strictCheck);
270 bool (*is_on_lan)(void* kodiBase, const char* path);
271 bool (*is_remote)(void* kodiBase, const char* path);
272 bool (*is_local)(void* kodiBase, const char* path);
273 bool (*is_url)(void* kodiBase, const char* path);
274 bool (*get_http_header)(void* kodiBase, const char* url, struct KODI_HTTP_HEADER* headers);
275 bool (*get_mime_type)(void* kodiBase, const char* url, char** content, const char* useragent);
276 bool (*get_content_type)(void* kodiBase,
277 const char* url,
278 char** content,
279 const char* useragent);
280 bool (*get_cookies)(void* kodiBase, const char* url, char** cookies);
281 bool (*http_header_create)(void* kodiBase, struct KODI_HTTP_HEADER* headers);
282 void (*http_header_free)(void* kodiBase, struct KODI_HTTP_HEADER* headers);
283
284 void* (*open_file)(void* kodiBase, const char* filename, unsigned int flags);
285 void* (*open_file_for_write)(void* kodiBase, const char* filename, bool overwrite);
286 ssize_t (*read_file)(void* kodiBase, void* file, void* ptr, size_t size);
287 bool (*read_file_string)(void* kodiBase, void* file, char* szLine, int iLineLength);
288 ssize_t (*write_file)(void* kodiBase, void* file, const void* ptr, size_t size);
289 void (*flush_file)(void* kodiBase, void* file);
290 int64_t (*seek_file)(void* kodiBase, void* file, int64_t position, int whence);
291 int (*truncate_file)(void* kodiBase, void* file, int64_t size);
292 int64_t (*get_file_position)(void* kodiBase, void* file);
293 int64_t (*get_file_length)(void* kodiBase, void* file);
294 double (*get_file_download_speed)(void* kodiBase, void* file);
295 void (*close_file)(void* kodiBase, void* file);
296 int (*get_file_chunk_size)(void* kodiBase, void* file);
297 bool (*io_control_get_seek_possible)(void* kodiBase, void* file);
298 bool (*io_control_get_cache_status)(void* kodiBase,
299 void* file,
300 struct VFS_CACHE_STATUS_DATA* status);
301 bool (*io_control_set_cache_rate)(void* kodiBase, void* file, unsigned int rate);
302 bool (*io_control_set_retry)(void* kodiBase, void* file, bool retry);
303 char** (*get_property_values)(
304 void* kodiBase, void* file, int type, const char* name, int* numValues);
305
306 void* (*curl_create)(void* kodiBase, const char* url);
307 bool (*curl_add_option)(
308 void* kodiBase, void* file, int type, const char* name, const char* value);
309 bool (*curl_open)(void* kodiBase, void* file, unsigned int flags);
310
311 bool (*get_disk_space)(
312 void* kodiBase, const char* path, uint64_t* capacity, uint64_t* free, uint64_t* available);
313 bool (*remove_directory_recursive)(void* kodiBase, const char* path);
315
316 //}}}
317
318#ifdef __cplusplus
319} /* extern "C" */
320#endif /* __cplusplus */
321
322#endif /* !C_API_FILESYSTEM_H */
CURLOptiontype
Definition: filesystem.h:109
@ ADDON_CURL_OPTION_PROTOCOL
Set a protocol option. The following names for ADDON_CURL_OPTION_PROTOCOL are possible:
Definition: filesystem.h:132
@ ADDON_CURL_OPTION_OPTION
Set a general option.
Definition: filesystem.h:111
@ ADDON_CURL_OPTION_HEADER
Add a Header.
Definition: filesystem.h:138
@ ADDON_CURL_OPTION_CREDENTIALS
Set User and password.
Definition: filesystem.h:135
FilePropertyTypes
Definition: filesystem.h:153
@ ADDON_FILE_PROPERTY_CONTENT_TYPE
Get file content type.
Definition: filesystem.h:159
@ ADDON_FILE_PROPERTY_EFFECTIVE_URL
Get file effective URL (last one if redirected).
Definition: filesystem.h:165
@ ADDON_FILE_PROPERTY_CONTENT_CHARSET
Get file content charset.
Definition: filesystem.h:161
@ ADDON_FILE_PROPERTY_MIME_TYPE
Get file mime type.
Definition: filesystem.h:163
@ ADDON_FILE_PROPERTY_RESPONSE_HEADER
Get a response header.
Definition: filesystem.h:157
@ ADDON_FILE_PROPERTY_RESPONSE_PROTOCOL
Get protocol response line.
Definition: filesystem.h:155
OpenFileFlags
Definition: filesystem.h:57
@ ADDON_READ_CACHED
0000 0000 0100 : Use cache to access this file.
Definition: filesystem.h:70
@ ADDON_READ_NO_CACHE
0000 0000 1000 : Open without caching. regardless to file type.
Definition: filesystem.h:74
@ ADDON_READ_AUDIO_VIDEO
0000 0100 0000 : indicate to the caller file is audio and/or video (and e.g. may grow).
Definition: filesystem.h:88
@ ADDON_READ_REOPEN
0001 0000 0000 : Indicate that caller want to reopen a file if its already open.
Definition: filesystem.h:96
@ ADDON_READ_AFTER_WRITE
0000 1000 0000 : Indicate that caller will do write operations before reading.
Definition: filesystem.h:92
@ ADDON_READ_TRUNCATED
0000 0000 0001 : Indicate that caller can handle truncated reads, where function returns before enti...
Definition: filesystem.h:61
@ ADDON_READ_CHUNKED
0000 0000 0010 : Indicate that that caller support read in the minimum defined chunk size,...
Definition: filesystem.h:66
@ ADDON_READ_MULTI_STREAM
0000 0010 0000 : Indicate to the caller we will seek between multiple streams in the file frequently...
Definition: filesystem.h:83
@ ADDON_READ_BITRATE
0000 0001 0000 : Calcuate bitrate for file while reading.
Definition: filesystem.h:78
Definition: filesystem.h:246
Definition: filesystem.h:177
Definition: filesystem.h:189
bool isRegular
The stat url is regular.
Definition: filesystem.h:211
uint32_t deviceId
ID of device containing file.
Definition: filesystem.h:191
uint64_t fileSerialNumber
Definition: filesystem.h:216
bool isBlock
The stat url is block special.
Definition: filesystem.h:205
bool isDirectory
The stat url is a directory.
Definition: filesystem.h:201
time_t accessTime
Time of last access.
Definition: filesystem.h:195
bool isSymLink
The stat url is a symbolic link.
Definition: filesystem.h:203
bool isFifo
The stat url is FIFO special.
Definition: filesystem.h:209
bool isSocket
The stat url is socket.
Definition: filesystem.h:213
time_t statusTime
Time of last status change.
Definition: filesystem.h:199
bool isCharacter
The stat url is character special.
Definition: filesystem.h:207
time_t modificationTime
Time of last modification.
Definition: filesystem.h:197
uint64_t size
Total size, in bytes.
Definition: filesystem.h:193
Definition: filesystem.h:220
Definition: filesystem.h:234
struct VFSProperty * properties
Properties.
Definition: filesystem.h:239
char * path
item path
Definition: filesystem.h:237
time_t date_time
file creation date & time
Definition: filesystem.h:240
unsigned int num_props
Number of properties attached to item.
Definition: filesystem.h:238
bool folder
Item is a folder.
Definition: filesystem.h:241
char * label
item label
Definition: filesystem.h:235
char * title
item title
Definition: filesystem.h:236
uint64_t size
Size of file represented by item.
Definition: filesystem.h:242
Definition: filesystem.h:228