summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-dev-kit/include/kodi/c-api/filesystem.h
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2020-10-19 00:52:24 +0200
committermanuel <manuel@mausz.at>2020-10-19 00:52:24 +0200
commitbe933ef2241d79558f91796cc5b3a161f72ebf9c (patch)
treefe3ab2f130e20c99001f2d7a81d610c78c96a3f4 /xbmc/addons/kodi-dev-kit/include/kodi/c-api/filesystem.h
parent5f8335c1e49ce108ef3481863833c98efa00411b (diff)
downloadkodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.gz
kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.bz2
kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.zip
sync with upstream
Diffstat (limited to 'xbmc/addons/kodi-dev-kit/include/kodi/c-api/filesystem.h')
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/filesystem.h325
1 files changed, 325 insertions, 0 deletions
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/filesystem.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/filesystem.h
new file mode 100644
index 0000000..70f9400
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/filesystem.h
@@ -0,0 +1,325 @@
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#pragma once
10
11#ifndef C_API_FILESYSTEM_H
12#define C_API_FILESYSTEM_H
13
14#include <stdbool.h>
15#include <stdint.h>
16#include <time.h>
17
18#ifdef _WIN32 // windows
19#ifndef _SSIZE_T_DEFINED
20typedef intptr_t ssize_t;
21#define _SSIZE_T_DEFINED
22#endif // !_SSIZE_T_DEFINED
23
24// Prevent conflicts with Windows macros where have this names.
25#ifdef CreateDirectory
26#undef CreateDirectory
27#endif // CreateDirectory
28#ifdef DeleteFile
29#undef DeleteFile
30#endif // DeleteFile
31#ifdef RemoveDirectory
32#undef RemoveDirectory
33#endif // RemoveDirectory
34#endif // _WIN32
35
36#ifdef TARGET_POSIX // Linux, Mac, FreeBSD
37#include <sys/types.h>
38#endif // TARGET_POSIX
39
40#ifdef __cplusplus
41extern "C"
42{
43#endif /* __cplusplus */
44
45 //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
46 // "C" Definitions, structures and enumerators of filesystem
47 //{{{
48
49 //============================================================================
50 /// @defgroup cpp_kodi_vfs_Defs_OpenFileFlags enum OpenFileFlags
51 /// @ingroup cpp_kodi_vfs_Defs
52 /// @brief **Flags to define way how file becomes opened**\n
53 /// The values can be used together, e.g. <b>`file.Open("myfile", ADDON_READ_TRUNCATED | ADDON_READ_CHUNKED);`</b>
54 ///
55 /// Used on @ref kodi::vfs::CFile::OpenFile().
56 ///
57 ///@{
58 typedef enum OpenFileFlags
59 {
60 /// @brief **0000 0000 0001** :\n
61 /// Indicate that caller can handle truncated reads, where function
62 /// returns before entire buffer has been filled.
63 ADDON_READ_TRUNCATED = 0x01,
64
65 /// @brief **0000 0000 0010** :\n
66 /// Indicate that that caller support read in the minimum defined
67 /// chunk size, this disables internal cache then.
68 ADDON_READ_CHUNKED = 0x02,
69
70 /// @brief **0000 0000 0100** :\n
71 /// Use cache to access this file.
72 ADDON_READ_CACHED = 0x04,
73
74 /// @brief **0000 0000 1000** :\n
75 /// Open without caching. regardless to file type.
76 ADDON_READ_NO_CACHE = 0x08,
77
78 /// @brief **0000 0001 0000** :\n
79 /// Calcuate bitrate for file while reading.
80 ADDON_READ_BITRATE = 0x10,
81
82 /// @brief **0000 0010 0000** :\n
83 /// Indicate to the caller we will seek between multiple streams in
84 /// the file frequently.
85 ADDON_READ_MULTI_STREAM = 0x20,
86
87 /// @brief **0000 0100 0000** :\n
88 /// indicate to the caller file is audio and/or video (and e.g. may
89 /// grow).
90 ADDON_READ_AUDIO_VIDEO = 0x40,
91
92 /// @brief **0000 1000 0000** :\n
93 /// Indicate that caller will do write operations before reading.
94 ADDON_READ_AFTER_WRITE = 0x80,
95
96 /// @brief **0001 0000 0000** :\n
97 /// Indicate that caller want to reopen a file if its already open.
98 ADDON_READ_REOPEN = 0x100
99 } OpenFileFlags;
100 ///@}
101 //----------------------------------------------------------------------------
102
103 //============================================================================
104 /// @defgroup cpp_kodi_vfs_Defs_CURLOptiontype enum CURLOptiontype
105 /// @ingroup cpp_kodi_vfs_Defs
106 /// @brief **CURL message types**\n
107 /// Used on kodi::vfs::CFile::CURLAddOption().
108 ///
109 //@{
110 typedef enum CURLOptiontype
111 {
112 /// @brief Set a general option.
113 ADDON_CURL_OPTION_OPTION,
114
115 /// @brief Set a protocol option.
116 ///
117 /// The following names for *ADDON_CURL_OPTION_PROTOCOL* are possible:
118 ///
119 /// | Option name | Description
120 /// |------------------------------------:|:--------------------------------
121 /// | <b>`accept-charset`</b> | Set the "accept-charset" header
122 /// | <b>`acceptencoding or encoding`</b> | Set the "accept-encoding" header
123 /// | <b>`active-remote`</b> | Set the "active-remote" header
124 /// | <b>`auth`</b> | Set the authentication method. Possible values: any, anysafe, digest, ntlm
125 /// | <b>`connection-timeout`</b> | Set the connection timeout in seconds
126 /// | <b>`cookie`</b> | Set the "cookie" header
127 /// | <b>`customrequest`</b> | Set a custom HTTP request like DELETE
128 /// | <b>`noshout`</b> | Set to true if kodi detects a stream as shoutcast by mistake.
129 /// | <b>`postdata`</b> | Set the post body (value needs to be base64 encoded). (Implicitly sets the request to POST)
130 /// | <b>`referer`</b> | Set the "referer" header
131 /// | <b>`user-agent`</b> | Set the "user-agent" header
132 /// | <b>`seekable`</b> | Set the stream seekable. 1: enable, 0: disable
133 /// | <b>`sslcipherlist`</b> | Set list of accepted SSL ciphers.
134 ///
135 ADDON_CURL_OPTION_PROTOCOL,
136
137 /// @brief Set User and password
138 ADDON_CURL_OPTION_CREDENTIALS,
139
140 /// @brief Add a Header
141 ADDON_CURL_OPTION_HEADER
142 } CURLOptiontype;
143 //@}
144 //----------------------------------------------------------------------------
145
146 //============================================================================
147 /// @defgroup cpp_kodi_vfs_Defs_FilePropertyTypes enum FilePropertyTypes
148 /// @ingroup cpp_kodi_vfs_Defs
149 /// @brief **File property types**\n
150 /// Mostly to read internet sources.
151 ///
152 /// Used on kodi::vfs::CFile::GetPropertyValue() and kodi::vfs::CFile::GetPropertyValues().
153 ///
154 //@{
155 typedef enum FilePropertyTypes
156 {
157 /// @brief Get protocol response line.
158 ADDON_FILE_PROPERTY_RESPONSE_PROTOCOL,
159 /// @brief Get a response header.
160 ADDON_FILE_PROPERTY_RESPONSE_HEADER,
161 /// @brief Get file content type.
162 ADDON_FILE_PROPERTY_CONTENT_TYPE,
163 /// @brief Get file content charset.
164 ADDON_FILE_PROPERTY_CONTENT_CHARSET,
165 /// @brief Get file mime type.
166 ADDON_FILE_PROPERTY_MIME_TYPE,
167 /// @brief Get file effective URL (last one if redirected).
168 ADDON_FILE_PROPERTY_EFFECTIVE_URL
169 } FilePropertyTypes;
170 //@}
171 //----------------------------------------------------------------------------
172
173 //}}}
174
175 //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
176 // "C" Internal interface tables for intercommunications between addon and kodi
177 //{{{
178
179 struct KODI_HTTP_HEADER
180 {
181 void* handle;
182
183 char* (*get_value)(void* kodiBase, void* handle, const char* param);
184 char** (*get_values)(void* kodiBase, void* handle, const char* param, int* length);
185 char* (*get_header)(void* kodiBase, void* handle);
186 char* (*get_mime_type)(void* kodiBase, void* handle);
187 char* (*get_charset)(void* kodiBase, void* handle);
188 char* (*get_proto_line)(void* kodiBase, void* handle);
189 };
190
191 struct STAT_STRUCTURE
192 {
193 /// ID of device containing file
194 uint32_t deviceId;
195 /// Total size, in bytes
196 uint64_t size;
197 /// Time of last access
198 time_t accessTime;
199 /// Time of last modification
200 time_t modificationTime;
201 /// Time of last status change
202 time_t statusTime;
203 /// The stat url is a directory
204 bool isDirectory;
205 /// The stat url is a symbolic link
206 bool isSymLink;
207 /// The stat url is block special
208 bool isBlock;
209 /// The stat url is character special
210 bool isCharacter;
211 /// The stat url is FIFO special
212 bool isFifo;
213 /// The stat url is regular
214 bool isRegular;
215 /// The stat url is socket
216 bool isSocket;
217 /// The file serial number, which distinguishes this file from all other files on the same
218 /// device.
219 uint64_t fileSerialNumber;
220 };
221
222 struct VFS_CACHE_STATUS_DATA
223 {
224 uint64_t forward;
225 unsigned int maxrate;
226 unsigned int currate;
227 bool lowspeed;
228 };
229
230 struct VFSProperty
231 {
232 char* name;
233 char* val;
234 };
235
236 struct VFSDirEntry
237 {
238 char* label; //!< item label
239 char* title; //!< item title
240 char* path; //!< item path
241 unsigned int num_props; //!< Number of properties attached to item
242 struct VFSProperty* properties; //!< Properties
243 time_t date_time; //!< file creation date & time
244 bool folder; //!< Item is a folder
245 uint64_t size; //!< Size of file represented by item
246 };
247
248 typedef struct AddonToKodiFuncTable_kodi_filesystem
249 {
250 bool (*can_open_directory)(void* kodiBase, const char* url);
251 bool (*create_directory)(void* kodiBase, const char* path);
252 bool (*remove_directory)(void* kodiBase, const char* path);
253 bool (*directory_exists)(void* kodiBase, const char* path);
254 bool (*get_directory)(void* kodiBase,
255 const char* path,
256 const char* mask,
257 struct VFSDirEntry** items,
258 unsigned int* num_items);
259 void (*free_directory)(void* kodiBase, struct VFSDirEntry* items, unsigned int num_items);
260
261 bool (*file_exists)(void* kodiBase, const char* filename, bool useCache);
262 bool (*stat_file)(void* kodiBase, const char* filename, struct STAT_STRUCTURE* buffer);
263 bool (*delete_file)(void* kodiBase, const char* filename);
264 bool (*rename_file)(void* kodiBase, const char* filename, const char* newFileName);
265 bool (*copy_file)(void* kodiBase, const char* filename, const char* dest);
266
267 char* (*get_file_md5)(void* kodiBase, const char* filename);
268 char* (*get_cache_thumb_name)(void* kodiBase, const char* filename);
269 char* (*make_legal_filename)(void* kodiBase, const char* filename);
270 char* (*make_legal_path)(void* kodiBase, const char* path);
271 char* (*translate_special_protocol)(void* kodiBase, const char* strSource);
272 bool (*is_internet_stream)(void* kodiBase, const char* path, bool strictCheck);
273 bool (*is_on_lan)(void* kodiBase, const char* path);
274 bool (*is_remote)(void* kodiBase, const char* path);
275 bool (*is_local)(void* kodiBase, const char* path);
276 bool (*is_url)(void* kodiBase, const char* path);
277 bool (*get_http_header)(void* kodiBase, const char* url, struct KODI_HTTP_HEADER* headers);
278 bool (*get_mime_type)(void* kodiBase, const char* url, char** content, const char* useragent);
279 bool (*get_content_type)(void* kodiBase,
280 const char* url,
281 char** content,
282 const char* useragent);
283 bool (*get_cookies)(void* kodiBase, const char* url, char** cookies);
284 bool (*http_header_create)(void* kodiBase, struct KODI_HTTP_HEADER* headers);
285 void (*http_header_free)(void* kodiBase, struct KODI_HTTP_HEADER* headers);
286
287 void* (*open_file)(void* kodiBase, const char* filename, unsigned int flags);
288 void* (*open_file_for_write)(void* kodiBase, const char* filename, bool overwrite);
289 ssize_t (*read_file)(void* kodiBase, void* file, void* ptr, size_t size);
290 bool (*read_file_string)(void* kodiBase, void* file, char* szLine, int iLineLength);
291 ssize_t (*write_file)(void* kodiBase, void* file, const void* ptr, size_t size);
292 void (*flush_file)(void* kodiBase, void* file);
293 int64_t (*seek_file)(void* kodiBase, void* file, int64_t position, int whence);
294 int (*truncate_file)(void* kodiBase, void* file, int64_t size);
295 int64_t (*get_file_position)(void* kodiBase, void* file);
296 int64_t (*get_file_length)(void* kodiBase, void* file);
297 double (*get_file_download_speed)(void* kodiBase, void* file);
298 void (*close_file)(void* kodiBase, void* file);
299 int (*get_file_chunk_size)(void* kodiBase, void* file);
300 bool (*io_control_get_seek_possible)(void* kodiBase, void* file);
301 bool (*io_control_get_cache_status)(void* kodiBase,
302 void* file,
303 struct VFS_CACHE_STATUS_DATA* status);
304 bool (*io_control_set_cache_rate)(void* kodiBase, void* file, unsigned int rate);
305 bool (*io_control_set_retry)(void* kodiBase, void* file, bool retry);
306 char** (*get_property_values)(
307 void* kodiBase, void* file, int type, const char* name, int* numValues);
308
309 void* (*curl_create)(void* kodiBase, const char* url);
310 bool (*curl_add_option)(
311 void* kodiBase, void* file, int type, const char* name, const char* value);
312 bool (*curl_open)(void* kodiBase, void* file, unsigned int flags);
313
314 bool (*get_disk_space)(
315 void* kodiBase, const char* path, uint64_t* capacity, uint64_t* free, uint64_t* available);
316 bool (*remove_directory_recursive)(void* kodiBase, const char* path);
317 } AddonToKodiFuncTable_kodi_filesystem;
318
319 //}}}
320
321#ifdef __cplusplus
322} /* extern "C" */
323#endif /* __cplusplus */
324
325#endif /* !C_API_FILESYSTEM_H */