Kodi Development 22.0
for Binary and Script based Add-Ons
 
Loading...
Searching...
No Matches
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
18#include <BaseTsd.h>
19typedef SSIZE_T ssize_t;
20#define _SSIZE_T_DEFINED
21#endif // !_SSIZE_T_DEFINED
22
23// Prevent conflicts with Windows macros where have this names.
24#ifdef CreateDirectory
25#undef CreateDirectory
26#endif // CreateDirectory
27#ifdef DeleteFile
28#undef DeleteFile
29#endif // DeleteFile
30#ifdef RemoveDirectory
31#undef RemoveDirectory
32#endif // RemoveDirectory
33#endif // _WIN32
34
35#ifdef TARGET_POSIX // Linux, Mac, FreeBSD
36#include <sys/types.h>
37#endif // TARGET_POSIX
38
39#ifdef __cplusplus
40extern "C"
41{
42#endif /* __cplusplus */
43
44 //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
45 // "C" Definitions, structures and enumerators of filesystem
46 //{{{
47
48 //============================================================================
108 //----------------------------------------------------------------------------
109
110 //============================================================================
151 //----------------------------------------------------------------------------
152
153 //============================================================================
178 //----------------------------------------------------------------------------
179
180 //}}}
181
182 //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
183 // "C" Internal interface tables for intercommunications between addon and kodi
184 //{{{
185
187 {
188 void* handle;
189
190 char* (*get_value)(void* kodiBase, void* handle, const char* param);
191 char** (*get_values)(void* kodiBase, void* handle, const char* param, int* length);
192 char* (*get_header)(void* kodiBase, void* handle);
193 char* (*get_mime_type)(void* kodiBase, void* handle);
194 char* (*get_charset)(void* kodiBase, void* handle);
195 char* (*get_proto_line)(void* kodiBase, void* handle);
196 };
197
199 {
201 uint32_t deviceId;
203 uint64_t size;
219 bool isFifo;
227 };
228
230 {
231 uint64_t forward;
232 uint32_t maxrate;
233 uint32_t currate;
234 uint32_t lowrate;
235 };
236
238 {
239 char* name;
240 char* val;
241 };
242
244 {
245 char* label;
246 char* title;
247 char* path;
248 unsigned int num_props;
250 time_t date_time;
251 bool folder;
252 uint64_t size;
253 };
254
256 {
257 bool (*can_open_directory)(void* kodiBase, const char* url);
258 bool (*create_directory)(void* kodiBase, const char* path);
259 bool (*remove_directory)(void* kodiBase, const char* path);
260 bool (*directory_exists)(void* kodiBase, const char* path);
261 bool (*get_directory)(void* kodiBase,
262 const char* path,
263 const char* mask,
264 struct VFSDirEntry** items,
265 unsigned int* num_items);
266 void (*free_directory)(void* kodiBase, struct VFSDirEntry* items, unsigned int num_items);
267
268 bool (*file_exists)(void* kodiBase, const char* filename, bool useCache);
269 bool (*stat_file)(void* kodiBase, const char* filename, struct STAT_STRUCTURE* buffer);
270 bool (*delete_file)(void* kodiBase, const char* filename);
271 bool (*rename_file)(void* kodiBase, const char* filename, const char* newFileName);
272 bool (*copy_file)(void* kodiBase, const char* filename, const char* dest);
273
274 char* (*get_file_md5)(void* kodiBase, const char* filename);
275 char* (*get_cache_thumb_name)(void* kodiBase, const char* filename);
276 char* (*make_legal_filename)(void* kodiBase, const char* filename);
277 char* (*make_legal_path)(void* kodiBase, const char* path);
278 char* (*translate_special_protocol)(void* kodiBase, const char* strSource);
279 bool (*is_internet_stream)(void* kodiBase, const char* path, bool strictCheck);
280 bool (*is_on_lan)(void* kodiBase, const char* path);
281 bool (*is_remote)(void* kodiBase, const char* path);
282 bool (*is_local)(void* kodiBase, const char* path);
283 bool (*is_url)(void* kodiBase, const char* path);
284 bool (*get_http_header)(void* kodiBase, const char* url, struct KODI_HTTP_HEADER* headers);
285 bool (*get_mime_type)(void* kodiBase, const char* url, char** content, const char* useragent);
286 bool (*get_content_type)(void* kodiBase,
287 const char* url,
288 char** content,
289 const char* useragent);
290 bool (*get_cookies)(void* kodiBase, const char* url, char** cookies);
291 bool (*http_header_create)(void* kodiBase, struct KODI_HTTP_HEADER* headers);
292 void (*http_header_free)(void* kodiBase, struct KODI_HTTP_HEADER* headers);
293
294 void* (*open_file)(void* kodiBase, const char* filename, unsigned int flags);
295 void* (*open_file_for_write)(void* kodiBase, const char* filename, bool overwrite);
296 ssize_t (*read_file)(void* kodiBase, void* file, void* ptr, size_t size);
297 bool (*read_file_string)(void* kodiBase, void* file, char* szLine, int iLineLength);
298 ssize_t (*write_file)(void* kodiBase, void* file, const void* ptr, size_t size);
299 void (*flush_file)(void* kodiBase, void* file);
300 int64_t (*seek_file)(void* kodiBase, void* file, int64_t position, int whence);
301 int (*truncate_file)(void* kodiBase, void* file, int64_t size);
302 int64_t (*get_file_position)(void* kodiBase, void* file);
303 int64_t (*get_file_length)(void* kodiBase, void* file);
304 double (*get_file_download_speed)(void* kodiBase, void* file);
305 void (*close_file)(void* kodiBase, void* file);
306 int (*get_file_chunk_size)(void* kodiBase, void* file);
307 bool (*io_control_get_seek_possible)(void* kodiBase, void* file);
308 bool (*io_control_get_cache_status)(void* kodiBase,
309 void* file,
310 struct VFS_CACHE_STATUS_DATA* status);
311 bool (*io_control_set_cache_rate)(void* kodiBase, void* file, uint32_t rate);
312 bool (*io_control_set_retry)(void* kodiBase, void* file, bool retry);
313 char** (*get_property_values)(
314 void* kodiBase, void* file, int type, const char* name, int* numValues);
315
316 void* (*curl_create)(void* kodiBase, const char* url);
317 bool (*curl_add_option)(
318 void* kodiBase, void* file, int type, const char* name, const char* value);
319 bool (*curl_open)(void* kodiBase, void* file, unsigned int flags);
320
321 bool (*get_disk_space)(
322 void* kodiBase, const char* path, uint64_t* capacity, uint64_t* free, uint64_t* available);
323 bool (*remove_directory_recursive)(void* kodiBase, const char* path);
325
326 //}}}
327
328#ifdef __cplusplus
329} /* extern "C" */
330#endif /* __cplusplus */
331
332#endif /* !C_API_FILESYSTEM_H */
CURLOptiontype
Definition filesystem.h:118
@ ADDON_CURL_OPTION_PROTOCOL
Set a protocol option. .
Definition filesystem.h:142
@ ADDON_CURL_OPTION_OPTION
Set a general option.
Definition filesystem.h:120
@ ADDON_CURL_OPTION_HEADER
Add a Header.
Definition filesystem.h:148
@ ADDON_CURL_OPTION_CREDENTIALS
Set User and password.
Definition filesystem.h:145
FilePropertyTypes
Definition filesystem.h:163
@ ADDON_FILE_PROPERTY_CONTENT_TYPE
Get file content type.
Definition filesystem.h:169
@ ADDON_FILE_PROPERTY_EFFECTIVE_URL
Get file effective URL (last one if redirected).
Definition filesystem.h:175
@ ADDON_FILE_PROPERTY_CONTENT_CHARSET
Get file content charset.
Definition filesystem.h:171
@ ADDON_FILE_PROPERTY_MIME_TYPE
Get file mime type.
Definition filesystem.h:173
@ ADDON_FILE_PROPERTY_RESPONSE_HEADER
Get a response header.
Definition filesystem.h:167
@ ADDON_FILE_PROPERTY_RESPONSE_PROTOCOL
Get protocol response line.
Definition filesystem.h:165
OpenFileFlags
Definition filesystem.h:58
@ ADDON_READ_CACHED
0000 0000 0100 : Use cache to access this file.
Definition filesystem.h:74
@ ADDON_READ_NO_CACHE
0000 0000 1000 : Open without caching. regardless to file type.
Definition filesystem.h:78
@ ADDON_READ_NO_BUFFER
0010 0000 0000 : Indicate that caller want open a file without intermediate buffer regardless to file...
Definition filesystem.h:105
@ ADDON_READ_AUDIO_VIDEO
0000 0100 0000 : Indicate to the caller file is audio and/or video and is suitable for caching with F...
Definition filesystem.h:93
@ ADDON_READ_REOPEN
0001 0000 0000 : Indicate that caller want to reopen a file if its already open.
Definition filesystem.h:101
@ ADDON_READ_AFTER_WRITE
0000 1000 0000 : Indicate that caller will do write operations before reading.
Definition filesystem.h:97
@ ADDON_READ_TRUNCATED
0000 0000 0001 : Indicate that caller can handle truncated reads, where function returns before entir...
Definition filesystem.h:62
@ ADDON_READ_CHUNKED
0000 0000 0010 : Indicate that that caller support read in the minimum defined chunk size,...
Definition filesystem.h:70
@ ADDON_READ_MULTI_STREAM
0000 0010 0000 : Indicate to the caller we will seek between multiple streams in the file frequently.
Definition filesystem.h:87
@ ADDON_READ_BITRATE
0000 0001 0000 : Calculate bitrate for file while reading.
Definition filesystem.h:82
Definition filesystem.h:256
Definition filesystem.h:187
Definition filesystem.h:199
bool isRegular
The stat url is regular.
Definition filesystem.h:221
uint32_t deviceId
ID of device containing file.
Definition filesystem.h:201
uint64_t fileSerialNumber
Definition filesystem.h:226
bool isBlock
The stat url is block special.
Definition filesystem.h:215
bool isDirectory
The stat url is a directory.
Definition filesystem.h:211
time_t accessTime
Time of last access.
Definition filesystem.h:205
bool isSymLink
The stat url is a symbolic link.
Definition filesystem.h:213
bool isFifo
The stat url is FIFO special.
Definition filesystem.h:219
bool isSocket
The stat url is socket.
Definition filesystem.h:223
time_t statusTime
Time of last status change.
Definition filesystem.h:209
bool isCharacter
The stat url is character special.
Definition filesystem.h:217
time_t modificationTime
Time of last modification.
Definition filesystem.h:207
uint64_t size
Total size, in bytes.
Definition filesystem.h:203
Definition filesystem.h:230
Definition filesystem.h:244
struct VFSProperty * properties
Properties.
Definition filesystem.h:249
char * path
item path
Definition filesystem.h:247
time_t date_time
file creation date & time
Definition filesystem.h:250
unsigned int num_props
Number of properties attached to item.
Definition filesystem.h:248
bool folder
Item is a folder.
Definition filesystem.h:251
char * label
item label
Definition filesystem.h:245
char * title
item title
Definition filesystem.h:246
uint64_t size
Size of file represented by item.
Definition filesystem.h:252
Definition filesystem.h:238