Kodi Development 22.0
for Binary and Script based Add-Ons
 
Loading...
Searching...
No Matches
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
16namespace kodi
17{
18namespace addon
19{
20
21class CInstanceVFS;
22
23//==============================================================================
33using VFSFileHandle = VFS_FILE_HANDLE;
35//------------------------------------------------------------------------------
36
37//==============================================================================
50class ATTR_DLL_LOCAL VFSUrl : public CStructHdl<VFSUrl, VFSURL>
51{
53 friend class CInstanceVFS;
56public:
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
144private:
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//==============================================================================
429//------------------------------------------------------------------------------
430class ATTR_DLL_LOCAL CInstanceVFS : public IAddonInstance
431{
432public:
433 //============================================================================
445 explicit CInstanceVFS(const IInstanceInfo& instance) : IAddonInstance(instance)
446 {
447 if (CPrivateBase::m_interface->globalSingleInstance != nullptr)
448 throw std::logic_error("kodi::addon::CInstanceVFS: Creation of multiple together with single "
449 "instance way is not allowed!");
450
451 SetAddonStruct(instance);
452 }
453 //----------------------------------------------------------------------------
454
455 //============================================================================
459 ~CInstanceVFS() override = default;
460 //----------------------------------------------------------------------------
461
462 //============================================================================
470
471 //============================================================================
479
481 //============================================================================
493 virtual kodi::addon::VFSFileHandle Open(const kodi::addon::VFSUrl& url) { return nullptr; }
494 //----------------------------------------------------------------------------
495
496 //============================================================================
505 {
506 return nullptr;
507 }
508 //----------------------------------------------------------------------------
509
510 //============================================================================
517 virtual bool Close(kodi::addon::VFSFileHandle context) { return false; }
518 //----------------------------------------------------------------------------
519
520 //============================================================================
529 virtual ssize_t Read(kodi::addon::VFSFileHandle context, uint8_t* buffer, size_t uiBufSize)
530 {
531 return -1;
532 }
533 //----------------------------------------------------------------------------
534
535 //============================================================================
544 virtual ssize_t Write(kodi::addon::VFSFileHandle context, const uint8_t* buffer, size_t uiBufSize)
545 {
546 return -1;
547 }
548 //----------------------------------------------------------------------------
549
550 //============================================================================
564 virtual int64_t Seek(kodi::addon::VFSFileHandle context, int64_t position, int whence)
565 {
566 return -1;
567 }
568 //----------------------------------------------------------------------------
569
570 //============================================================================
578 virtual int Truncate(kodi::addon::VFSFileHandle context, int64_t size) { return -1; }
579 //----------------------------------------------------------------------------
580
581 //============================================================================
588 virtual int64_t GetLength(kodi::addon::VFSFileHandle context) { return 0; }
589 //----------------------------------------------------------------------------
590
591 //============================================================================
598 virtual int64_t GetPosition(kodi::addon::VFSFileHandle context) { return 0; }
599 //----------------------------------------------------------------------------
600
601 //============================================================================
608 virtual int GetChunkSize(kodi::addon::VFSFileHandle context) { return 1; }
609 //----------------------------------------------------------------------------
610
611 //============================================================================
617 virtual bool IoControlGetSeekPossible(kodi::addon::VFSFileHandle context) { return false; }
618 //----------------------------------------------------------------------------
619
620 //============================================================================
632 {
633 return false;
634 }
635 //----------------------------------------------------------------------------
636
637 //============================================================================
644 virtual bool IoControlSetCacheRate(kodi::addon::VFSFileHandle context, uint32_t rate)
645 {
646 return false;
647 }
648 //----------------------------------------------------------------------------
649
650 //============================================================================
657 virtual bool IoControlSetRetry(kodi::addon::VFSFileHandle context, bool retry) { return false; }
658 //----------------------------------------------------------------------------
660
662 //============================================================================
675 virtual int Stat(const kodi::addon::VFSUrl& url, kodi::vfs::FileStatus& buffer) { return 0; }
676 //----------------------------------------------------------------------------
677
678 //============================================================================
685 virtual bool Exists(const kodi::addon::VFSUrl& url) { return false; }
686 //----------------------------------------------------------------------------
687
688 //============================================================================
692 virtual void ClearOutIdle() {}
693 //----------------------------------------------------------------------------
694
695 //============================================================================
699 virtual void DisconnectAll() {}
700 //----------------------------------------------------------------------------
701
702 //============================================================================
709 virtual bool Delete(const kodi::addon::VFSUrl& url) { return false; }
710 //----------------------------------------------------------------------------
711
712 //============================================================================
720 virtual bool Rename(const kodi::addon::VFSUrl& url, const kodi::addon::VFSUrl& url2)
721 {
722 return false;
723 }
724 //----------------------------------------------------------------------------
725
726 //============================================================================
733 virtual bool DirectoryExists(const kodi::addon::VFSUrl& url) { return false; }
734 //----------------------------------------------------------------------------
735
736 //============================================================================
743 virtual bool RemoveDirectory(const kodi::addon::VFSUrl& url) { return false; }
744 //----------------------------------------------------------------------------
745
746 //============================================================================
753 virtual bool CreateDirectory(const kodi::addon::VFSUrl& url) { return false; }
754 //----------------------------------------------------------------------------
755
756 //============================================================================
790 {
791 public:
804 bool GetKeyboardInput(const std::string& heading, std::string& input, bool hiddenInput = false)
805 {
806 char* cInput = nullptr;
807 bool ret = m_cb->get_keyboard_input(m_cb->ctx, heading.c_str(), &cInput, hiddenInput);
808 if (cInput)
809 {
810 input = cInput;
811 ::kodi::addon::CPrivateBase::m_interface->toKodi->free_string(
812 ::kodi::addon::CPrivateBase::m_interface->toKodi->kodiBase, cInput);
813 }
814 return ret;
815 }
816
825 void SetErrorDialog(const std::string& heading,
826 const std::string& line1,
827 const std::string& line2 = "",
828 const std::string& line3 = "")
829 {
830 m_cb->set_error_dialog(m_cb->ctx, heading.c_str(), line1.c_str(), line2.c_str(),
831 line3.c_str());
832 }
833
838 void RequireAuthentication(const std::string& url)
839 {
840 m_cb->require_authentication(m_cb->ctx, url.c_str());
841 }
842
843 explicit CVFSCallbacks(const VFSGetDirectoryCallbacks* cb) : m_cb(cb) {}
844
845 private:
846 const VFSGetDirectoryCallbacks* m_cb;
847 };
848 //----------------------------------------------------------------------------
849
850 //============================================================================
874 virtual bool GetDirectory(const kodi::addon::VFSUrl& url,
875 std::vector<kodi::vfs::CDirEntry>& entries,
876 CVFSCallbacks callbacks)
877 {
878 return false;
879 }
880 //----------------------------------------------------------------------------
881
882 //============================================================================
893 virtual bool ContainsFiles(const kodi::addon::VFSUrl& url,
894 std::vector<kodi::vfs::CDirEntry>& entries,
895 std::string& rootPath)
896 {
897 return false;
898 }
899 //----------------------------------------------------------------------------
901
902private:
903 void SetAddonStruct(KODI_ADDON_INSTANCE_STRUCT* instance)
904 {
905 m_instanceData = instance;
906 m_instanceData->hdl = this;
907 m_instanceData->vfs->toAddon->addonInstance = this;
908 m_instanceData->vfs->toAddon->open = ADDON_Open;
909 m_instanceData->vfs->toAddon->open_for_write = ADDON_OpenForWrite;
910 m_instanceData->vfs->toAddon->read = ADDON_Read;
911 m_instanceData->vfs->toAddon->write = ADDON_Write;
912 m_instanceData->vfs->toAddon->seek = ADDON_Seek;
913 m_instanceData->vfs->toAddon->truncate = ADDON_Truncate;
914 m_instanceData->vfs->toAddon->get_length = ADDON_GetLength;
915 m_instanceData->vfs->toAddon->get_position = ADDON_GetPosition;
916 m_instanceData->vfs->toAddon->get_chunk_size = ADDON_GetChunkSize;
917 m_instanceData->vfs->toAddon->io_control_get_seek_possible = ADDON_IoControlGetSeekPossible;
918 m_instanceData->vfs->toAddon->io_control_get_cache_status = ADDON_IoControlGetCacheStatus;
919 m_instanceData->vfs->toAddon->io_control_set_cache_rate = ADDON_IoControlSetCacheRate;
920 m_instanceData->vfs->toAddon->io_control_set_retry = ADDON_IoControlSetRetry;
921 m_instanceData->vfs->toAddon->stat = ADDON_Stat;
922 m_instanceData->vfs->toAddon->close = ADDON_Close;
923 m_instanceData->vfs->toAddon->exists = ADDON_Exists;
924 m_instanceData->vfs->toAddon->clear_out_idle = ADDON_ClearOutIdle;
925 m_instanceData->vfs->toAddon->disconnect_all = ADDON_DisconnectAll;
926 m_instanceData->vfs->toAddon->delete_it = ADDON_Delete;
927 m_instanceData->vfs->toAddon->rename = ADDON_Rename;
928 m_instanceData->vfs->toAddon->directory_exists = ADDON_DirectoryExists;
929 m_instanceData->vfs->toAddon->remove_directory = ADDON_RemoveDirectory;
930 m_instanceData->vfs->toAddon->create_directory = ADDON_CreateDirectory;
931 m_instanceData->vfs->toAddon->get_directory = ADDON_GetDirectory;
932 m_instanceData->vfs->toAddon->free_directory = ADDON_FreeDirectory;
933 m_instanceData->vfs->toAddon->contains_files = ADDON_ContainsFiles;
934 }
935
936 inline static VFS_FILE_HANDLE ADDON_Open(const AddonInstance_VFSEntry* instance,
937 const VFSURL* url)
938 {
939 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Open(url);
940 }
941
942 inline static VFS_FILE_HANDLE ADDON_OpenForWrite(const AddonInstance_VFSEntry* instance,
943 const VFSURL* url,
944 bool overWrite)
945 {
946 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
947 ->OpenForWrite(url, overWrite);
948 }
949
950 inline static ssize_t ADDON_Read(const AddonInstance_VFSEntry* instance,
951 VFS_FILE_HANDLE context,
952 uint8_t* buffer,
953 size_t uiBufSize)
954 {
955 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
956 ->Read(context, buffer, uiBufSize);
957 }
958
959 inline static ssize_t ADDON_Write(const AddonInstance_VFSEntry* instance,
960 VFS_FILE_HANDLE context,
961 const uint8_t* buffer,
962 size_t uiBufSize)
963 {
964 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
965 ->Write(context, buffer, uiBufSize);
966 }
967
968 inline static int64_t ADDON_Seek(const AddonInstance_VFSEntry* instance,
969 VFS_FILE_HANDLE context,
970 int64_t position,
971 int whence)
972 {
973 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
974 ->Seek(context, position, whence);
975 }
976
977 inline static int ADDON_Truncate(const AddonInstance_VFSEntry* instance,
978 VFS_FILE_HANDLE context,
979 int64_t size)
980 {
981 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Truncate(context, size);
982 }
983
984 inline static int64_t ADDON_GetLength(const AddonInstance_VFSEntry* instance,
985 VFS_FILE_HANDLE context)
986 {
987 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->GetLength(context);
988 }
989
990 inline static int64_t ADDON_GetPosition(const AddonInstance_VFSEntry* instance,
991 VFS_FILE_HANDLE context)
992 {
993 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->GetPosition(context);
994 }
995
996 inline static int ADDON_GetChunkSize(const AddonInstance_VFSEntry* instance,
997 VFS_FILE_HANDLE context)
998 {
999 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->GetChunkSize(context);
1000 }
1001
1002 inline static bool ADDON_IoControlGetSeekPossible(const AddonInstance_VFSEntry* instance,
1003 VFS_FILE_HANDLE context)
1004 {
1005 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
1006 ->IoControlGetSeekPossible(context);
1007 }
1008
1009 inline static bool ADDON_IoControlGetCacheStatus(const struct AddonInstance_VFSEntry* instance,
1010 VFS_FILE_HANDLE context,
1011 VFS_CACHE_STATUS_DATA* status)
1012 {
1013 kodi::vfs::CacheStatus cppStatus(status);
1014 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
1015 ->IoControlGetCacheStatus(context, cppStatus);
1016 }
1017
1018 inline static bool ADDON_IoControlSetCacheRate(const struct AddonInstance_VFSEntry* instance,
1019 VFS_FILE_HANDLE context,
1020 uint32_t rate)
1021 {
1022 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
1023 ->IoControlSetCacheRate(context, rate);
1024 }
1025
1026 inline static bool ADDON_IoControlSetRetry(const struct AddonInstance_VFSEntry* instance,
1027 VFS_FILE_HANDLE context,
1028 bool retry)
1029 {
1030 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
1031 ->IoControlSetRetry(context, retry);
1032 }
1033
1034 inline static int ADDON_Stat(const AddonInstance_VFSEntry* instance,
1035 const VFSURL* url,
1036 struct STAT_STRUCTURE* buffer)
1037 {
1038 kodi::vfs::FileStatus cppBuffer(buffer);
1039 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Stat(url, cppBuffer);
1040 }
1041
1042 inline static bool ADDON_Close(const AddonInstance_VFSEntry* instance, VFS_FILE_HANDLE context)
1043 {
1044 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Close(context);
1045 }
1046
1047 inline static bool ADDON_Exists(const AddonInstance_VFSEntry* instance, const VFSURL* url)
1048 {
1049 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Exists(url);
1050 }
1051
1052 inline static void ADDON_ClearOutIdle(const AddonInstance_VFSEntry* instance)
1053 {
1054 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->ClearOutIdle();
1055 }
1056
1057 inline static void ADDON_DisconnectAll(const AddonInstance_VFSEntry* instance)
1058 {
1059 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->DisconnectAll();
1060 }
1061
1062 inline static bool ADDON_Delete(const AddonInstance_VFSEntry* instance, const VFSURL* url)
1063 {
1064 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Delete(url);
1065 }
1066
1067 inline static bool ADDON_Rename(const AddonInstance_VFSEntry* instance,
1068 const VFSURL* url,
1069 const VFSURL* url2)
1070 {
1071 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Rename(url, url2);
1072 }
1073
1074 inline static bool ADDON_DirectoryExists(const AddonInstance_VFSEntry* instance,
1075 const VFSURL* url)
1076 {
1077 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->DirectoryExists(url);
1078 }
1079
1080 inline static bool ADDON_RemoveDirectory(const AddonInstance_VFSEntry* instance,
1081 const VFSURL* url)
1082 {
1083 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->RemoveDirectory(url);
1084 }
1085
1086 inline static bool ADDON_CreateDirectory(const AddonInstance_VFSEntry* instance,
1087 const VFSURL* url)
1088 {
1089 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->CreateDirectory(url);
1090 }
1091
1092 inline static bool ADDON_GetDirectory(const AddonInstance_VFSEntry* instance,
1093 const VFSURL* url,
1094 VFSDirEntry** retEntries,
1095 int* num_entries,
1096 VFSGetDirectoryCallbacks* callbacks)
1097 {
1098 std::vector<kodi::vfs::CDirEntry> addonEntries;
1099 bool ret = static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
1100 ->GetDirectory(url, addonEntries, CVFSCallbacks(callbacks));
1101 if (ret)
1102 {
1103 VFSDirEntry* entries =
1104 static_cast<VFSDirEntry*>(malloc(sizeof(VFSDirEntry) * addonEntries.size()));
1105 for (unsigned int i = 0; i < addonEntries.size(); ++i)
1106 {
1107 entries[i].label = strdup(addonEntries[i].Label().c_str());
1108 entries[i].title = strdup(addonEntries[i].Title().c_str());
1109 entries[i].path = strdup(addonEntries[i].Path().c_str());
1110 entries[i].folder = addonEntries[i].IsFolder();
1111 entries[i].size = addonEntries[i].Size();
1112 entries[i].date_time = addonEntries[i].DateTime();
1113
1114 entries[i].num_props = 0;
1115 const std::map<std::string, std::string>& props = addonEntries[i].GetProperties();
1116 if (!props.empty())
1117 {
1118 entries[i].properties =
1119 static_cast<VFSProperty*>(malloc(sizeof(VFSProperty) * props.size()));
1120 for (const auto& prop : props)
1121 {
1122 entries[i].properties[entries[i].num_props].name = strdup(prop.first.c_str());
1123 entries[i].properties[entries[i].num_props].val = strdup(prop.second.c_str());
1124 ++entries[i].num_props;
1125 }
1126 }
1127 else
1128 entries[i].properties = nullptr;
1129 }
1130 *retEntries = entries;
1131 *num_entries = static_cast<int>(addonEntries.size());
1132 }
1133 return ret;
1134 }
1135
1136 inline static void ADDON_FreeDirectory(const AddonInstance_VFSEntry* instance,
1137 VFSDirEntry* entries,
1138 int num_entries)
1139 {
1140 for (int i = 0; i < num_entries; ++i)
1141 {
1142 if (entries[i].properties)
1143 {
1144 for (unsigned int j = 0; j < entries[i].num_props; ++j)
1145 {
1146 free(entries[i].properties[j].name);
1147 free(entries[i].properties[j].val);
1148 }
1149 free(entries[i].properties);
1150 }
1151 free(entries[i].label);
1152 free(entries[i].title);
1153 free(entries[i].path);
1154 }
1155 free(entries);
1156 }
1157
1158 inline static bool ADDON_ContainsFiles(const AddonInstance_VFSEntry* instance,
1159 const VFSURL* url,
1160 VFSDirEntry** retEntries,
1161 int* num_entries,
1162 char* rootpath)
1163 {
1164 std::string cppRootPath;
1165 std::vector<kodi::vfs::CDirEntry> addonEntries;
1166 bool ret = static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
1167 ->ContainsFiles(url, addonEntries, cppRootPath);
1168 if (ret)
1169 {
1170 strncpy(rootpath, cppRootPath.c_str(), ADDON_STANDARD_STRING_LENGTH);
1171
1172 VFSDirEntry* entries =
1173 static_cast<VFSDirEntry*>(malloc(sizeof(VFSDirEntry) * addonEntries.size()));
1174 for (size_t i = 0; i < addonEntries.size(); ++i)
1175 {
1176 entries[i].label = strdup(addonEntries[i].Label().c_str());
1177 entries[i].title = strdup(addonEntries[i].Title().c_str());
1178 entries[i].path = strdup(addonEntries[i].Path().c_str());
1179 entries[i].folder = addonEntries[i].IsFolder();
1180 entries[i].size = addonEntries[i].Size();
1181 entries[i].date_time = addonEntries[i].DateTime();
1182
1183 entries[i].num_props = 0;
1184 const std::map<std::string, std::string>& props = addonEntries[i].GetProperties();
1185 if (!props.empty())
1186 {
1187 entries[i].properties =
1188 static_cast<VFSProperty*>(malloc(sizeof(VFSProperty) * props.size()));
1189 for (const auto& prop : props)
1190 {
1191 entries[i].properties[entries[i].num_props].name = strdup(prop.first.c_str());
1192 entries[i].properties[entries[i].num_props].val = strdup(prop.second.c_str());
1193 ++entries[i].num_props;
1194 }
1195 }
1196 else
1197 entries[i].properties = nullptr;
1198 }
1199 *retEntries = entries;
1200 *num_entries = static_cast<int>(addonEntries.size());
1201 }
1202 return ret;
1203 }
1204
1205 KODI_ADDON_INSTANCE_STRUCT* m_instanceData{nullptr};
1206};
1207
1208} /* namespace addon */
1209} /* namespace kodi */
1210
1211#endif /* __cplusplus */
Definition VFS.h:431
Definition AddonBase.h:206
Definition AddonBase.h:565
Definition AddonBase.h:498
Definition VFS.h:51
Definition Filesystem.h:229
Definition Filesystem.h:96
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 cl...
Definition VFS.h:33
virtual kodi::addon::VFSFileHandle Open(const kodi::addon::VFSUrl &url)
Open a file for input.
Definition VFS.h:493
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:630
virtual ssize_t Read(kodi::addon::VFSFileHandle context, uint8_t *buffer, size_t uiBufSize)
Read from a file.
Definition VFS.h:529
virtual int64_t Seek(kodi::addon::VFSFileHandle context, int64_t position, int whence)
Seek in a file.
Definition VFS.h:564
virtual int Truncate(kodi::addon::VFSFileHandle context, int64_t size)
Truncate a file.
Definition VFS.h:578
virtual int GetChunkSize(kodi::addon::VFSFileHandle context)
Get chunk size of a file.
Definition VFS.h:608
virtual int64_t GetPosition(kodi::addon::VFSFileHandle context)
Get current position in a file.
Definition VFS.h:598
virtual ssize_t Write(kodi::addon::VFSFileHandle context, const uint8_t *buffer, size_t uiBufSize)
Write to a file.
Definition VFS.h:544
virtual bool IoControlGetSeekPossible(kodi::addon::VFSFileHandle context)
To check seek possible on current stream by file.
Definition VFS.h:617
virtual bool IoControlSetCacheRate(kodi::addon::VFSFileHandle context, uint32_t rate)
Unsigned int with speed limit for caching in bytes per second.
Definition VFS.h:644
virtual bool Close(kodi::addon::VFSFileHandle context)
Close a file.
Definition VFS.h:517
virtual bool IoControlSetRetry(kodi::addon::VFSFileHandle context, bool retry)
Enable/disable retry within the protocol handler (if supported).
Definition VFS.h:657
virtual int64_t GetLength(kodi::addon::VFSFileHandle context)
Get total size of a file.
Definition VFS.h:588
virtual kodi::addon::VFSFileHandle OpenForWrite(const kodi::addon::VFSUrl &url, bool overWrite)
Open a file for output.
Definition VFS.h:504
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:825
bool GetKeyboardInput(const std::string &heading, std::string &input, bool hiddenInput=false)
Require keyboard input.
Definition VFS.h:804
void RequireAuthentication(const std::string &url)
Prompt the user for authentication of a URL.
Definition VFS.h:838
virtual void ClearOutIdle()
Clear out any idle connections.
Definition VFS.h:692
virtual int Stat(const kodi::addon::VFSUrl &url, kodi::vfs::FileStatus &buffer)
Stat a file.
Definition VFS.h:675
virtual bool RemoveDirectory(const kodi::addon::VFSUrl &url)
Remove a directory.
Definition VFS.h:743
virtual void DisconnectAll()
Disconnect all connections.
Definition VFS.h:699
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:893
virtual bool CreateDirectory(const kodi::addon::VFSUrl &url)
Create a directory.
Definition VFS.h:753
virtual bool GetDirectory(const kodi::addon::VFSUrl &url, std::vector< kodi::vfs::CDirEntry > &entries, CVFSCallbacks callbacks)
List a directory.
Definition VFS.h:874
virtual bool Delete(const kodi::addon::VFSUrl &url)
Delete a file.
Definition VFS.h:709
virtual bool Exists(const kodi::addon::VFSUrl &url)
Check for file existence.
Definition VFS.h:685
virtual bool DirectoryExists(const kodi::addon::VFSUrl &url)
Check for directory existence.
Definition VFS.h:733
virtual bool Rename(const kodi::addon::VFSUrl &url, const kodi::addon::VFSUrl &url2)
Rename a file.
Definition VFS.h:720
CInstanceVFS(const IInstanceInfo &instance)
VFS class constructor used to support multiple instance types.
Definition VFS.h:445
~CInstanceVFS() override=default
Destructor.
bool ATTR_DLL_LOCAL CreateDirectory(const std::string &path)
Make a directory.
Definition Filesystem.h:778
bool ATTR_DLL_LOCAL RemoveDirectory(const std::string &path, bool recursive=false)
Removes a directory.
Definition Filesystem.h:844
bool ATTR_DLL_LOCAL GetDirectory(const std::string &path, const std::string &mask, std::vector< kodi::vfs::CDirEntry > &items)
Lists a directory.
Definition Filesystem.h:893
bool ATTR_DLL_LOCAL DirectoryExists(const std::string &path)
Verifying the Existence of a Directory.
Definition Filesystem.h:810
unsigned int ATTR_DLL_LOCAL 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:1458
Definition vfs.h:137
Definition addon_base.h:268
Definition filesystem.h:198
Definition filesystem.h:229
Definition filesystem.h:243
struct VFSProperty * properties
Properties.
Definition filesystem.h:248
char * path
item path
Definition filesystem.h:246
time_t date_time
file creation date & time
Definition filesystem.h:249
unsigned int num_props
Number of properties attached to item.
Definition filesystem.h:247
bool folder
Item is a folder.
Definition filesystem.h:250
char * label
item label
Definition filesystem.h:244
char * title
item title
Definition filesystem.h:245
uint64_t size
Size of file represented by item.
Definition filesystem.h:251
Definition vfs.h:37
Definition filesystem.h:237
Definition vfs.h:22