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