Kodi Development  20.0
for Binary and Script based Add-Ons
VFS.h
1 /*
2  * Copyright (C) 2015-2018 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 #include "../AddonBase.h"
11 #include "../Filesystem.h"
12 #include "../c-api/addon-instance/vfs.h"
13 
14 #ifdef __cplusplus
15 
16 namespace kodi
17 {
18 namespace addon
19 {
20 
21 class CInstanceVFS;
22 
23 //==============================================================================
33 using VFSFileHandle = VFS_FILE_HANDLE;
35 //------------------------------------------------------------------------------
36 
37 //==============================================================================
50 class ATTRIBUTE_HIDDEN VFSUrl : public CStructHdl<VFSUrl, VFSURL>
51 {
53  friend class CInstanceVFS;
56 public:
75 
78 
85  std::string GetURL() const { return m_cStructure->url; }
86 
89  std::string GetDomain() const { return m_cStructure->domain; }
90 
94  std::string GetHostname() const { return m_cStructure->hostname; }
95 
98  std::string GetFilename() const { return m_cStructure->filename; }
99 
102  unsigned int GetPort() const { return m_cStructure->port; }
103 
118  std::string GetOptions() const { return m_cStructure->options; }
119 
121  std::string GetUsername() const { return m_cStructure->username; }
122 
124  std::string GetPassword() const { return m_cStructure->password; }
125 
130  std::string GetRedacted() const { return m_cStructure->redacted; }
131 
137  std::string GetSharename() const { return m_cStructure->sharename; }
138 
140  std::string GetProtocol() const { return m_cStructure->protocol; }
141 
143 
144 private:
145  VFSUrl() = delete;
146  VFSUrl(const VFSUrl& channel) = delete;
147  VFSUrl(const VFSURL* channel) : CStructHdl(channel) {}
148  VFSUrl(VFSURL* channel) : CStructHdl(channel) {}
149 };
151 //------------------------------------------------------------------------------
152 
153 //##############################################################################
161 
162 //==============================================================================
435 //------------------------------------------------------------------------------
436 class ATTRIBUTE_HIDDEN CInstanceVFS : public IAddonInstance
437 {
438 public:
439  //============================================================================
455  explicit CInstanceVFS(KODI_HANDLE instance, const std::string& kodiVersion = "")
457  !kodiVersion.empty() ? kodiVersion : GetKodiTypeVersion(ADDON_INSTANCE_VFS))
458  {
459  if (CAddonBase::m_interface->globalSingleInstance != nullptr)
460  throw std::logic_error("kodi::addon::CInstanceVFS: Creation of multiple together with single "
461  "instance way is not allowed!");
462 
463  SetAddonStruct(instance);
464  }
465  //----------------------------------------------------------------------------
466 
467  //============================================================================
471  ~CInstanceVFS() override = default;
472  //----------------------------------------------------------------------------
473 
474  //============================================================================
482 
483  //============================================================================
491 
493  //============================================================================
505  virtual kodi::addon::VFSFileHandle Open(const kodi::addon::VFSUrl& url) { return nullptr; }
506  //----------------------------------------------------------------------------
507 
508  //============================================================================
516  virtual kodi::addon::VFSFileHandle OpenForWrite(const kodi::addon::VFSUrl& url, bool overWrite)
517  {
518  return nullptr;
519  }
520  //----------------------------------------------------------------------------
521 
522  //============================================================================
529  virtual bool Close(kodi::addon::VFSFileHandle context) { return false; }
530  //----------------------------------------------------------------------------
531 
532  //============================================================================
541  virtual ssize_t Read(kodi::addon::VFSFileHandle context, uint8_t* buffer, size_t uiBufSize)
542  {
543  return -1;
544  }
545  //----------------------------------------------------------------------------
546 
547  //============================================================================
556  virtual ssize_t Write(kodi::addon::VFSFileHandle context, const uint8_t* buffer, size_t uiBufSize)
557  {
558  return -1;
559  }
560  //----------------------------------------------------------------------------
561 
562  //============================================================================
576  virtual int64_t Seek(kodi::addon::VFSFileHandle context, int64_t position, int whence)
577  {
578  return -1;
579  }
580  //----------------------------------------------------------------------------
581 
582  //============================================================================
590  virtual int Truncate(kodi::addon::VFSFileHandle context, int64_t size) { return -1; }
591  //----------------------------------------------------------------------------
592 
593  //============================================================================
600  virtual int64_t GetLength(kodi::addon::VFSFileHandle context) { return 0; }
601  //----------------------------------------------------------------------------
602 
603  //============================================================================
610  virtual int64_t GetPosition(kodi::addon::VFSFileHandle context) { return 0; }
611  //----------------------------------------------------------------------------
612 
613  //============================================================================
620  virtual int GetChunkSize(kodi::addon::VFSFileHandle context) { return 1; }
621  //----------------------------------------------------------------------------
622 
623  //============================================================================
629  virtual bool IoControlGetSeekPossible(kodi::addon::VFSFileHandle context) { return false; }
630  //----------------------------------------------------------------------------
631 
632  //============================================================================
643  kodi::vfs::CacheStatus& status)
644  {
645  return false;
646  }
647  //----------------------------------------------------------------------------
648 
649  //============================================================================
656  virtual bool IoControlSetCacheRate(kodi::addon::VFSFileHandle context, unsigned int rate)
657  {
658  return false;
659  }
660  //----------------------------------------------------------------------------
661 
662  //============================================================================
669  virtual bool IoControlSetRetry(kodi::addon::VFSFileHandle context, bool retry) { return false; }
670  //----------------------------------------------------------------------------
672 
674  //============================================================================
687  virtual int Stat(const kodi::addon::VFSUrl& url, kodi::vfs::FileStatus& buffer) { return 0; }
688  //----------------------------------------------------------------------------
689 
690  //============================================================================
697  virtual bool Exists(const kodi::addon::VFSUrl& url) { return false; }
698  //----------------------------------------------------------------------------
699 
700  //============================================================================
704  virtual void ClearOutIdle() {}
705  //----------------------------------------------------------------------------
706 
707  //============================================================================
711  virtual void DisconnectAll() {}
712  //----------------------------------------------------------------------------
713 
714  //============================================================================
721  virtual bool Delete(const kodi::addon::VFSUrl& url) { return false; }
722  //----------------------------------------------------------------------------
723 
724  //============================================================================
732  virtual bool Rename(const kodi::addon::VFSUrl& url, const kodi::addon::VFSUrl& url2)
733  {
734  return false;
735  }
736  //----------------------------------------------------------------------------
737 
738  //============================================================================
745  virtual bool DirectoryExists(const kodi::addon::VFSUrl& url) { return false; }
746  //----------------------------------------------------------------------------
747 
748  //============================================================================
755  virtual bool RemoveDirectory(const kodi::addon::VFSUrl& url) { return false; }
756  //----------------------------------------------------------------------------
757 
758  //============================================================================
765  virtual bool CreateDirectory(const kodi::addon::VFSUrl& url) { return false; }
766  //----------------------------------------------------------------------------
767 
768  //============================================================================
802  {
803  public:
816  bool GetKeyboardInput(const std::string& heading, std::string& input, bool hiddenInput = false)
817  {
818  char* cInput = nullptr;
819  bool ret = m_cb->get_keyboard_input(m_cb->ctx, heading.c_str(), &cInput, hiddenInput);
820  if (cInput)
821  {
822  input = cInput;
823  ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(
824  ::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, cInput);
825  }
826  return ret;
827  }
828 
837  void SetErrorDialog(const std::string& heading,
838  const std::string& line1,
839  const std::string& line2 = "",
840  const std::string& line3 = "")
841  {
842  m_cb->set_error_dialog(m_cb->ctx, heading.c_str(), line1.c_str(), line2.c_str(),
843  line3.c_str());
844  }
845 
850  void RequireAuthentication(const std::string& url)
851  {
852  m_cb->require_authentication(m_cb->ctx, url.c_str());
853  }
854 
855  explicit CVFSCallbacks(const VFSGetDirectoryCallbacks* cb) : m_cb(cb) {}
856 
857  private:
858  const VFSGetDirectoryCallbacks* m_cb;
859  };
860  //----------------------------------------------------------------------------
861 
862  //============================================================================
886  virtual bool GetDirectory(const kodi::addon::VFSUrl& url,
887  std::vector<kodi::vfs::CDirEntry>& entries,
888  CVFSCallbacks callbacks)
889  {
890  return false;
891  }
892  //----------------------------------------------------------------------------
893 
894  //============================================================================
905  virtual bool ContainsFiles(const kodi::addon::VFSUrl& url,
906  std::vector<kodi::vfs::CDirEntry>& entries,
907  std::string& rootPath)
908  {
909  return false;
910  }
911  //----------------------------------------------------------------------------
913 
914 private:
915  void SetAddonStruct(KODI_HANDLE instance)
916  {
917  if (instance == nullptr)
918  throw std::logic_error("kodi::addon::CInstanceVFS: Creation with empty addon structure not "
919  "allowed, table must be given from Kodi!");
920 
921  m_instanceData = static_cast<AddonInstance_VFSEntry*>(instance);
922  m_instanceData->toAddon->addonInstance = this;
923  m_instanceData->toAddon->open = ADDON_Open;
924  m_instanceData->toAddon->open_for_write = ADDON_OpenForWrite;
925  m_instanceData->toAddon->read = ADDON_Read;
926  m_instanceData->toAddon->write = ADDON_Write;
927  m_instanceData->toAddon->seek = ADDON_Seek;
928  m_instanceData->toAddon->truncate = ADDON_Truncate;
929  m_instanceData->toAddon->get_length = ADDON_GetLength;
930  m_instanceData->toAddon->get_position = ADDON_GetPosition;
931  m_instanceData->toAddon->get_chunk_size = ADDON_GetChunkSize;
932  m_instanceData->toAddon->io_control_get_seek_possible = ADDON_IoControlGetSeekPossible;
933  m_instanceData->toAddon->io_control_get_cache_status = ADDON_IoControlGetCacheStatus;
934  m_instanceData->toAddon->io_control_set_cache_rate = ADDON_IoControlSetCacheRate;
935  m_instanceData->toAddon->io_control_set_retry = ADDON_IoControlSetRetry;
936  m_instanceData->toAddon->stat = ADDON_Stat;
937  m_instanceData->toAddon->close = ADDON_Close;
938  m_instanceData->toAddon->exists = ADDON_Exists;
939  m_instanceData->toAddon->clear_out_idle = ADDON_ClearOutIdle;
940  m_instanceData->toAddon->disconnect_all = ADDON_DisconnectAll;
941  m_instanceData->toAddon->delete_it = ADDON_Delete;
942  m_instanceData->toAddon->rename = ADDON_Rename;
943  m_instanceData->toAddon->directory_exists = ADDON_DirectoryExists;
944  m_instanceData->toAddon->remove_directory = ADDON_RemoveDirectory;
945  m_instanceData->toAddon->create_directory = ADDON_CreateDirectory;
946  m_instanceData->toAddon->get_directory = ADDON_GetDirectory;
947  m_instanceData->toAddon->free_directory = ADDON_FreeDirectory;
948  m_instanceData->toAddon->contains_files = ADDON_ContainsFiles;
949  }
950 
951  inline static VFS_FILE_HANDLE ADDON_Open(const AddonInstance_VFSEntry* instance,
952  const VFSURL* url)
953  {
954  return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Open(url);
955  }
956 
957  inline static VFS_FILE_HANDLE ADDON_OpenForWrite(const AddonInstance_VFSEntry* instance,
958  const VFSURL* url,
959  bool overWrite)
960  {
961  return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
962  ->OpenForWrite(url, overWrite);
963  }
964 
965  inline static ssize_t ADDON_Read(const AddonInstance_VFSEntry* instance,
966  VFS_FILE_HANDLE context,
967  uint8_t* buffer,
968  size_t uiBufSize)
969  {
970  return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
971  ->Read(context, buffer, uiBufSize);
972  }
973 
974  inline static ssize_t ADDON_Write(const AddonInstance_VFSEntry* instance,
975  VFS_FILE_HANDLE context,
976  const uint8_t* buffer,
977  size_t uiBufSize)
978  {
979  return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
980  ->Write(context, buffer, uiBufSize);
981  }
982 
983  inline static int64_t ADDON_Seek(const AddonInstance_VFSEntry* instance,
984  VFS_FILE_HANDLE context,
985  int64_t position,
986  int whence)
987  {
988  return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
989  ->Seek(context, position, whence);
990  }
991 
992  inline static int ADDON_Truncate(const AddonInstance_VFSEntry* instance,
993  VFS_FILE_HANDLE context,
994  int64_t size)
995  {
996  return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Truncate(context, size);
997  }
998 
999  inline static int64_t ADDON_GetLength(const AddonInstance_VFSEntry* instance,
1000  VFS_FILE_HANDLE context)
1001  {
1002  return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->GetLength(context);
1003  }
1004 
1005  inline static int64_t ADDON_GetPosition(const AddonInstance_VFSEntry* instance,
1006  VFS_FILE_HANDLE context)
1007  {
1008  return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->GetPosition(context);
1009  }
1010 
1011  inline static int ADDON_GetChunkSize(const AddonInstance_VFSEntry* instance,
1012  VFS_FILE_HANDLE context)
1013  {
1014  return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->GetChunkSize(context);
1015  }
1016 
1017  inline static bool ADDON_IoControlGetSeekPossible(const AddonInstance_VFSEntry* instance,
1018  VFS_FILE_HANDLE context)
1019  {
1020  return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
1021  ->IoControlGetSeekPossible(context);
1022  }
1023 
1024  inline static bool ADDON_IoControlGetCacheStatus(const struct AddonInstance_VFSEntry* instance,
1025  VFS_FILE_HANDLE context,
1026  VFS_CACHE_STATUS_DATA* status)
1027  {
1028  kodi::vfs::CacheStatus cppStatus(status);
1029  return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
1030  ->IoControlGetCacheStatus(context, cppStatus);
1031  }
1032 
1033  inline static bool ADDON_IoControlSetCacheRate(const struct AddonInstance_VFSEntry* instance,
1034  VFS_FILE_HANDLE context,
1035  unsigned int rate)
1036  {
1037  return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
1038  ->IoControlSetCacheRate(context, rate);
1039  }
1040 
1041  inline static bool ADDON_IoControlSetRetry(const struct AddonInstance_VFSEntry* instance,
1042  VFS_FILE_HANDLE context,
1043  bool retry)
1044  {
1045  return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
1046  ->IoControlSetRetry(context, retry);
1047  }
1048 
1049  inline static int ADDON_Stat(const AddonInstance_VFSEntry* instance,
1050  const VFSURL* url,
1051  struct STAT_STRUCTURE* buffer)
1052  {
1053  kodi::vfs::FileStatus cppBuffer(buffer);
1054  return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Stat(url, cppBuffer);
1055  }
1056 
1057  inline static bool ADDON_Close(const AddonInstance_VFSEntry* instance, VFS_FILE_HANDLE context)
1058  {
1059  return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Close(context);
1060  }
1061 
1062  inline static bool ADDON_Exists(const AddonInstance_VFSEntry* instance, const VFSURL* url)
1063  {
1064  return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Exists(url);
1065  }
1066 
1067  inline static void ADDON_ClearOutIdle(const AddonInstance_VFSEntry* instance)
1068  {
1069  return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->ClearOutIdle();
1070  }
1071 
1072  inline static void ADDON_DisconnectAll(const AddonInstance_VFSEntry* instance)
1073  {
1074  return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->DisconnectAll();
1075  }
1076 
1077  inline static bool ADDON_Delete(const AddonInstance_VFSEntry* instance, const VFSURL* url)
1078  {
1079  return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Delete(url);
1080  }
1081 
1082  inline static bool ADDON_Rename(const AddonInstance_VFSEntry* instance,
1083  const VFSURL* url,
1084  const VFSURL* url2)
1085  {
1086  return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Rename(url, url2);
1087  }
1088 
1089  inline static bool ADDON_DirectoryExists(const AddonInstance_VFSEntry* instance,
1090  const VFSURL* url)
1091  {
1092  return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->DirectoryExists(url);
1093  }
1094 
1095  inline static bool ADDON_RemoveDirectory(const AddonInstance_VFSEntry* instance,
1096  const VFSURL* url)
1097  {
1098  return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->RemoveDirectory(url);
1099  }
1100 
1101  inline static bool ADDON_CreateDirectory(const AddonInstance_VFSEntry* instance,
1102  const VFSURL* url)
1103  {
1104  return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->CreateDirectory(url);
1105  }
1106 
1107  inline static bool ADDON_GetDirectory(const AddonInstance_VFSEntry* instance,
1108  const VFSURL* url,
1109  VFSDirEntry** retEntries,
1110  int* num_entries,
1111  VFSGetDirectoryCallbacks* callbacks)
1112  {
1113  std::vector<kodi::vfs::CDirEntry> addonEntries;
1114  bool ret = static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
1115  ->GetDirectory(url, addonEntries, CVFSCallbacks(callbacks));
1116  if (ret)
1117  {
1118  VFSDirEntry* entries =
1119  static_cast<VFSDirEntry*>(malloc(sizeof(VFSDirEntry) * addonEntries.size()));
1120  for (unsigned int i = 0; i < addonEntries.size(); ++i)
1121  {
1122  entries[i].label = strdup(addonEntries[i].Label().c_str());
1123  entries[i].title = strdup(addonEntries[i].Title().c_str());
1124  entries[i].path = strdup(addonEntries[i].Path().c_str());
1125  entries[i].folder = addonEntries[i].IsFolder();
1126  entries[i].size = addonEntries[i].Size();
1127  entries[i].date_time = addonEntries[i].DateTime();
1128 
1129  entries[i].num_props = 0;
1130  const std::map<std::string, std::string>& props = addonEntries[i].GetProperties();
1131  if (!props.empty())
1132  {
1133  entries[i].properties =
1134  static_cast<VFSProperty*>(malloc(sizeof(VFSProperty) * props.size()));
1135  for (const auto& prop : props)
1136  {
1137  entries[i].properties[entries[i].num_props].name = strdup(prop.first.c_str());
1138  entries[i].properties[entries[i].num_props].val = strdup(prop.second.c_str());
1139  ++entries[i].num_props;
1140  }
1141  }
1142  else
1143  entries[i].properties = nullptr;
1144  }
1145  *retEntries = entries;
1146  *num_entries = static_cast<int>(addonEntries.size());
1147  }
1148  return ret;
1149  }
1150 
1151  inline static void ADDON_FreeDirectory(const AddonInstance_VFSEntry* instance,
1152  VFSDirEntry* entries,
1153  int num_entries)
1154  {
1155  for (int i = 0; i < num_entries; ++i)
1156  {
1157  if (entries[i].properties)
1158  {
1159  for (unsigned int j = 0; j < entries[i].num_props; ++j)
1160  {
1161  free(entries[i].properties[j].name);
1162  free(entries[i].properties[j].val);
1163  }
1164  free(entries[i].properties);
1165  }
1166  free(entries[i].label);
1167  free(entries[i].title);
1168  free(entries[i].path);
1169  }
1170  free(entries);
1171  }
1172 
1173  inline static bool ADDON_ContainsFiles(const AddonInstance_VFSEntry* instance,
1174  const VFSURL* url,
1175  VFSDirEntry** retEntries,
1176  int* num_entries,
1177  char* rootpath)
1178  {
1179  std::string cppRootPath;
1180  std::vector<kodi::vfs::CDirEntry> addonEntries;
1181  bool ret = static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
1182  ->ContainsFiles(url, addonEntries, cppRootPath);
1183  if (ret)
1184  {
1185  strncpy(rootpath, cppRootPath.c_str(), ADDON_STANDARD_STRING_LENGTH);
1186 
1187  VFSDirEntry* entries =
1188  static_cast<VFSDirEntry*>(malloc(sizeof(VFSDirEntry) * addonEntries.size()));
1189  for (size_t i = 0; i < addonEntries.size(); ++i)
1190  {
1191  entries[i].label = strdup(addonEntries[i].Label().c_str());
1192  entries[i].title = strdup(addonEntries[i].Title().c_str());
1193  entries[i].path = strdup(addonEntries[i].Path().c_str());
1194  entries[i].folder = addonEntries[i].IsFolder();
1195  entries[i].size = addonEntries[i].Size();
1196  entries[i].date_time = addonEntries[i].DateTime();
1197 
1198  entries[i].num_props = 0;
1199  const std::map<std::string, std::string>& props = addonEntries[i].GetProperties();
1200  if (!props.empty())
1201  {
1202  entries[i].properties =
1203  static_cast<VFSProperty*>(malloc(sizeof(VFSProperty) * props.size()));
1204  for (const auto& prop : props)
1205  {
1206  entries[i].properties[entries[i].num_props].name = strdup(prop.first.c_str());
1207  entries[i].properties[entries[i].num_props].val = strdup(prop.second.c_str());
1208  ++entries[i].num_props;
1209  }
1210  }
1211  else
1212  entries[i].properties = nullptr;
1213  }
1214  *retEntries = entries;
1215  *num_entries = static_cast<int>(addonEntries.size());
1216  }
1217  return ret;
1218  }
1219 
1220  AddonInstance_VFSEntry* m_instanceData;
1221 };
1222 
1223 } /* namespace addon */
1224 } /* namespace kodi */
1225 
1226 #endif /* __cplusplus */
Definition: VFS.h:437
Definition: AddonBase.h:250
Definition: AddonBase.h:186
Definition: VFS.h:51
Definition: Filesystem.h:226
Definition: Filesystem.h:96
@ ADDON_INSTANCE_VFS
Virtual Filesystem (VFS) instance, see kodi::addon::CInstanceVFS.
Definition: versions.h:241
std::string GetFilename() const
With this variable the desired path to a folder or file within the hostname is given (e....
Definition: VFS.h:98
std::string GetHostname() const
This includes the network address (e.g. 192.168.0.123) or if the addon refers to file packages the pa...
Definition: VFS.h:94
std::string GetSharename() const
The name which is taken as the basis by source and would be first in folder view.
Definition: VFS.h:137
std::string GetOptions() const
Special options on opened URL, this can e.g. on RAR packages ?flags=8&nextvalue=123 to inform about t...
Definition: VFS.h:118
std::string GetPassword() const
Desired password.
Definition: VFS.h:124
std::string GetURL() const
Desired URL of the file system to be edited.
Definition: VFS.h:85
std::string GetProtocol() const
Protocol name used on this stream, e.g. sftp.
Definition: VFS.h:140
std::string GetRedacted() const
The complete URL is passed on here, but the user name and password are not shown and only appear to t...
Definition: VFS.h:130
unsigned int GetPort() const
Networking port to use for protocol.
Definition: VFS.h:102
std::string GetUsername() const
Desired username.
Definition: VFS.h:121
std::string GetDomain() const
The associated domain name, which is optional and not available in all cases.
Definition: VFS.h:89
VFS_FILE_HANDLE VFSFileHandle
VFS add-on file handle This used to handle opened files of addon with related memory pointer about c...
Definition: VFS.h:33
virtual kodi::addon::VFSFileHandle Open(const kodi::addon::VFSUrl &url)
Open a file for input.
Definition: VFS.h:505
virtual bool IoControlGetCacheStatus(kodi::addon::VFSFileHandle context, kodi::vfs::CacheStatus &status)
To check a running stream on file for state of his cache.
Definition: VFS.h:642
virtual ssize_t Read(kodi::addon::VFSFileHandle context, uint8_t *buffer, size_t uiBufSize)
Read from a file.
Definition: VFS.h:541
virtual int64_t Seek(kodi::addon::VFSFileHandle context, int64_t position, int whence)
Seek in a file.
Definition: VFS.h:576
virtual int Truncate(kodi::addon::VFSFileHandle context, int64_t size)
Truncate a file.
Definition: VFS.h:590
virtual int GetChunkSize(kodi::addon::VFSFileHandle context)
Get chunk size of a file.
Definition: VFS.h:620
virtual int64_t GetPosition(kodi::addon::VFSFileHandle context)
Get current position in a file.
Definition: VFS.h:610
virtual ssize_t Write(kodi::addon::VFSFileHandle context, const uint8_t *buffer, size_t uiBufSize)
Write to a file.
Definition: VFS.h:556
virtual bool IoControlGetSeekPossible(kodi::addon::VFSFileHandle context)
To check seek possible on current stream by file.
Definition: VFS.h:629
virtual bool Close(kodi::addon::VFSFileHandle context)
Close a file.
Definition: VFS.h:529
virtual bool IoControlSetCacheRate(kodi::addon::VFSFileHandle context, unsigned int rate)
Unsigned int with speed limit for caching in bytes per second.
Definition: VFS.h:656
virtual bool IoControlSetRetry(kodi::addon::VFSFileHandle context, bool retry)
Enable/disable retry within the protocol handler (if supported).
Definition: VFS.h:669
virtual int64_t GetLength(kodi::addon::VFSFileHandle context)
Get total size of a file.
Definition: VFS.h:600
virtual kodi::addon::VFSFileHandle OpenForWrite(const kodi::addon::VFSUrl &url, bool overWrite)
Open a file for output.
Definition: VFS.h:516
void SetErrorDialog(const std::string &heading, const std::string &line1, const std::string &line2="", const std::string &line3="")
Display an error dialog.
Definition: VFS.h:837
bool GetKeyboardInput(const std::string &heading, std::string &input, bool hiddenInput=false)
Require keyboard input.
Definition: VFS.h:816
void RequireAuthentication(const std::string &url)
Prompt the user for authentication of a URL.
Definition: VFS.h:850
virtual void ClearOutIdle()
Clear out any idle connections.
Definition: VFS.h:704
virtual int Stat(const kodi::addon::VFSUrl &url, kodi::vfs::FileStatus &buffer)
Stat a file.
Definition: VFS.h:687
virtual bool RemoveDirectory(const kodi::addon::VFSUrl &url)
Remove a directory.
Definition: VFS.h:755
virtual void DisconnectAll()
Disconnect all connections.
Definition: VFS.h:711
virtual bool ContainsFiles(const kodi::addon::VFSUrl &url, std::vector< kodi::vfs::CDirEntry > &entries, std::string &rootPath)
Check if file should be presented as a directory (multiple streams)
Definition: VFS.h:905
virtual bool CreateDirectory(const kodi::addon::VFSUrl &url)
Create a directory.
Definition: VFS.h:765
virtual bool GetDirectory(const kodi::addon::VFSUrl &url, std::vector< kodi::vfs::CDirEntry > &entries, CVFSCallbacks callbacks)
List a directory.
Definition: VFS.h:886
virtual bool Delete(const kodi::addon::VFSUrl &url)
Delete a file.
Definition: VFS.h:721
virtual bool Exists(const kodi::addon::VFSUrl &url)
Check for file existence.
Definition: VFS.h:697
virtual bool DirectoryExists(const kodi::addon::VFSUrl &url)
Check for directory existence.
Definition: VFS.h:745
virtual bool Rename(const kodi::addon::VFSUrl &url, const kodi::addon::VFSUrl &url2)
Rename a file.
Definition: VFS.h:732
~CInstanceVFS() override=default
Destructor.
CInstanceVFS(KODI_HANDLE instance, const std::string &kodiVersion="")
VFS class constructor used to support multiple instance types.
Definition: VFS.h:455
bool ATTRIBUTE_HIDDEN CreateDirectory(const std::string &path)
Make a directory.
Definition: Filesystem.h:773
bool ATTRIBUTE_HIDDEN GetDirectory(const std::string &path, const std::string &mask, std::vector< kodi::vfs::CDirEntry > &items)
Lists a directory.
Definition: Filesystem.h:888
bool ATTRIBUTE_HIDDEN DirectoryExists(const std::string &path)
Verifying the Existence of a Directory.
Definition: Filesystem.h:805
bool ATTRIBUTE_HIDDEN RemoveDirectory(const std::string &path, bool recursive=false)
Removes a directory.
Definition: Filesystem.h:839
unsigned int ATTRIBUTE_HIDDEN GetChunkSize(unsigned int chunk, unsigned int minimum)
Return a size aligned to the chunk size at least as large as the chunk size.
Definition: Filesystem.h:1452
std::string ATTRIBUTE_HIDDEN GetKodiTypeVersion(int type)
To get used version inside Kodi itself about asked type.
Definition: AddonBase.h:630
Definition: vfs.h:137
Definition: filesystem.h:189
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: vfs.h:37
Definition: filesystem.h:228
Definition: vfs.h:22