Kodi Development  19.0
for Binary and Script based Add-Ons
vfs.h
1 /*
2  * Copyright (C) 2005-2020 Team Kodi
3  *
4  * SPDX-License-Identifier: GPL-2.0-or-later
5  * See LICENSES/README.md for more information.
6  */
7 
8 #pragma once
9 
10 #ifndef C_API_ADDONINSTANCE_VFS_H
11 #define C_API_ADDONINSTANCE_VFS_H
12 
13 #include "../addon_base.h"
14 #include "../filesystem.h"
15 
16 #define VFS_FILE_HANDLE void*
17 
18 #ifdef __cplusplus
19 extern "C"
20 {
21 #endif /* __cplusplus */
22 
23  struct VFSURL
24  {
25  const char* url;
26  const char* domain;
27  const char* hostname;
28  const char* filename;
29  unsigned int port;
30  const char* options;
31  const char* username;
32  const char* password;
33  const char* redacted;
34  const char* sharename;
35  const char* protocol;
36  };
37 
38  typedef struct VFSGetDirectoryCallbacks /* internal */
39  {
40  bool(__cdecl* get_keyboard_input)(KODI_HANDLE ctx,
41  const char* heading,
42  char** input,
43  bool hidden_input);
44  void(__cdecl* set_error_dialog)(KODI_HANDLE ctx,
45  const char* heading,
46  const char* line1,
47  const char* line2,
48  const char* line3);
49  void(__cdecl* require_authentication)(KODI_HANDLE ctx, const char* url);
50  KODI_HANDLE ctx;
52 
53  typedef struct AddonProps_VFSEntry /* internal */
54  {
55  int dummy;
57 
58  typedef struct AddonToKodiFuncTable_VFSEntry /* internal */
59  {
60  KODI_HANDLE kodiInstance;
62 
64  typedef struct KodiToAddonFuncTable_VFSEntry /* internal */
65  {
66  KODI_HANDLE addonInstance;
67 
68  VFS_FILE_HANDLE(__cdecl* open)
69  (const struct AddonInstance_VFSEntry* instance, const struct VFSURL* url);
70  VFS_FILE_HANDLE(__cdecl* open_for_write)
71  (const struct AddonInstance_VFSEntry* instance, const struct VFSURL* url, bool overwrite);
72  ssize_t(__cdecl* read)(const struct AddonInstance_VFSEntry* instance,
73  VFS_FILE_HANDLE context,
74  uint8_t* buffer,
75  size_t buf_size);
76  ssize_t(__cdecl* write)(const struct AddonInstance_VFSEntry* instance,
77  VFS_FILE_HANDLE context,
78  const uint8_t* buffer,
79  size_t buf_size);
80  int64_t(__cdecl* seek)(const struct AddonInstance_VFSEntry* instance,
81  VFS_FILE_HANDLE context,
82  int64_t position,
83  int whence);
84  int(__cdecl* truncate)(const struct AddonInstance_VFSEntry* instance,
85  VFS_FILE_HANDLE context,
86  int64_t size);
87  int64_t(__cdecl* get_length)(const struct AddonInstance_VFSEntry* instance,
88  VFS_FILE_HANDLE context);
89  int64_t(__cdecl* get_position)(const struct AddonInstance_VFSEntry* instance,
90  VFS_FILE_HANDLE context);
91  int(__cdecl* get_chunk_size)(const struct AddonInstance_VFSEntry* instance,
92  VFS_FILE_HANDLE context);
93  bool(__cdecl* io_control_get_seek_possible)(const struct AddonInstance_VFSEntry* instance,
94  VFS_FILE_HANDLE context);
95  bool(__cdecl* io_control_get_cache_status)(const struct AddonInstance_VFSEntry* instance,
96  VFS_FILE_HANDLE context,
97  VFS_CACHE_STATUS_DATA* status);
98  bool(__cdecl* io_control_set_cache_rate)(const struct AddonInstance_VFSEntry* instance,
99  VFS_FILE_HANDLE context,
100  unsigned int rate);
101  bool(__cdecl* io_control_set_retry)(const struct AddonInstance_VFSEntry* instance,
102  VFS_FILE_HANDLE context,
103  bool retry);
104  int(__cdecl* stat)(const struct AddonInstance_VFSEntry* instance,
105  const struct VFSURL* url,
106  struct STAT_STRUCTURE* buffer);
107  bool(__cdecl* close)(const struct AddonInstance_VFSEntry* instance, VFS_FILE_HANDLE context);
108 
109  bool(__cdecl* exists)(const struct AddonInstance_VFSEntry* instance, const struct VFSURL* url);
110  void(__cdecl* clear_out_idle)(const struct AddonInstance_VFSEntry* instance);
111  void(__cdecl* disconnect_all)(const struct AddonInstance_VFSEntry* instance);
112  bool(__cdecl* delete_it)(const struct AddonInstance_VFSEntry* instance,
113  const struct VFSURL* url);
114  bool(__cdecl* rename)(const struct AddonInstance_VFSEntry* instance,
115  const struct VFSURL* url,
116  const struct VFSURL* url2);
117  bool(__cdecl* directory_exists)(const struct AddonInstance_VFSEntry* instance,
118  const struct VFSURL* url);
119  bool(__cdecl* remove_directory)(const struct AddonInstance_VFSEntry* instance,
120  const struct VFSURL* url);
121  bool(__cdecl* create_directory)(const struct AddonInstance_VFSEntry* instance,
122  const struct VFSURL* url);
123  bool(__cdecl* get_directory)(const struct AddonInstance_VFSEntry* instance,
124  const struct VFSURL* url,
125  struct VFSDirEntry** entries,
126  int* num_entries,
127  struct VFSGetDirectoryCallbacks* callbacks);
128  bool(__cdecl* contains_files)(const struct AddonInstance_VFSEntry* instance,
129  const struct VFSURL* url,
130  struct VFSDirEntry** entries,
131  int* num_entries,
132  char* rootpath);
133  void(__cdecl* free_directory)(const struct AddonInstance_VFSEntry* instance,
134  struct VFSDirEntry* entries,
135  int num_entries);
137 
138  typedef struct AddonInstance_VFSEntry /* internal */
139  {
140  struct AddonProps_VFSEntry* props;
141  struct AddonToKodiFuncTable_VFSEntry* toKodi;
142  struct KodiToAddonFuncTable_VFSEntry* toAddon;
144 
145 #ifdef __cplusplus
146 } /* extern "C" */
147 #endif /* __cplusplus */
148 
149 #endif /* !C_API_ADDONINSTANCE_VFS_H */
rename
rename(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
VFSURL
Definition: vfs.h:24
KodiToAddonFuncTable_VFSEntry
Definition: vfs.h:65
exists
exists(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
VFSGetDirectoryCallbacks
Definition: vfs.h:39
AddonInstance_VFSEntry
Definition: vfs.h:139
AddonToKodiFuncTable_VFSEntry
Definition: vfs.h:59
AddonProps_VFSEntry
Definition: vfs.h:54
VFS_CACHE_STATUS_DATA
Definition: filesystem.h:223
VFSDirEntry
Definition: filesystem.h:237
STAT_STRUCTURE
Definition: filesystem.h:192