11 #include "AddonBase.h"
12 #include "c-api/filesystem.h"
132 void SetDeviceId(uint32_t deviceId) { m_cStructure->deviceId = deviceId; }
138 void SetFileSerialNumber(uint64_t fileSerialNumber) { m_cStructure->fileSerialNumber = fileSerialNumber; }
144 void SetSize(uint64_t size) { m_cStructure->size = size; }
147 uint64_t
GetSize()
const {
return m_cStructure->size; }
150 void SetAccessTime(time_t accessTime) { m_cStructure->accessTime = accessTime; }
158 m_cStructure->modificationTime = modificationTime;
165 void SetStatusTime(time_t statusTime) { m_cStructure->statusTime = statusTime; }
171 void SetIsDirectory(
bool isDirectory) { m_cStructure->isDirectory = isDirectory; }
177 void SetIsSymLink(
bool isSymLink) { m_cStructure->isSymLink = isSymLink; }
183 void SetIsBlock(
bool isBlock) { m_cStructure->isBlock = isBlock; }
189 void SetIsCharacter(
bool isCharacter) { m_cStructure->isCharacter = isCharacter; }
195 void SetIsFifo(
bool isFifo) { m_cStructure->isFifo = isFifo; }
201 void SetIsRegular(
bool isRegular) { m_cStructure->isRegular = isRegular; }
207 void SetIsSocket(
bool isSocket) { m_cStructure->isSocket = isSocket; }
253 void SetForward(uint64_t forward) { m_cStructure->forward = forward; }
259 void SetMaxRate(
unsigned int maxrate) { m_cStructure->maxrate = maxrate; }
271 void SetLowspeed(
bool lowspeed) { m_cStructure->lowspeed = lowspeed; }
302 using namespace ::kodi::addon;
304 CAddonBase::m_interface->toKodi->kodi_filesystem->http_header_create(
305 CAddonBase::m_interface->toKodi->kodiBase, &m_handle);
314 using namespace ::kodi::addon;
316 CAddonBase::m_interface->toKodi->kodi_filesystem->http_header_free(
317 CAddonBase::m_interface->toKodi->kodiBase, &m_handle);
345 std::string
GetValue(
const std::string& param)
const
347 using namespace ::kodi::addon;
349 if (!m_handle.handle)
352 std::string protoLine;
353 char*
string = m_handle.get_value(CAddonBase::m_interface->toKodi->kodiBase, m_handle.handle,
355 if (
string !=
nullptr)
358 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
372 std::vector<std::string>
GetValues(
const std::string& param)
const
374 using namespace kodi::addon;
376 if (!m_handle.handle)
377 return std::vector<std::string>();
380 char** res(m_handle.get_values(CAddonBase::m_interface->toKodi->kodiBase, m_handle.handle,
381 param.c_str(), &numValues));
384 std::vector<std::string> vecReturn;
385 vecReturn.reserve(numValues);
386 for (
int i = 0; i < numValues; ++i)
388 vecReturn.emplace_back(res[i]);
390 CAddonBase::m_interface->toKodi->free_string_array(CAddonBase::m_interface->toKodi->kodiBase,
394 return std::vector<std::string>();
405 using namespace ::kodi::addon;
407 if (!m_handle.handle)
411 char*
string = m_handle.get_header(CAddonBase::m_interface->toKodi->kodiBase, m_handle.handle);
412 if (
string !=
nullptr)
415 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
429 using namespace ::kodi::addon;
431 if (!m_handle.handle)
434 std::string protoLine;
436 m_handle.get_mime_type(CAddonBase::m_interface->toKodi->kodiBase, m_handle.handle);
437 if (
string !=
nullptr)
440 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
454 using namespace ::kodi::addon;
456 if (!m_handle.handle)
459 std::string protoLine;
460 char*
string = m_handle.get_charset(CAddonBase::m_interface->toKodi->kodiBase, m_handle.handle);
461 if (
string !=
nullptr)
464 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
478 using namespace ::kodi::addon;
480 if (!m_handle.handle)
483 std::string protoLine;
485 m_handle.get_proto_line(CAddonBase::m_interface->toKodi->kodiBase, m_handle.handle);
486 if (
string !=
nullptr)
489 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
556 const std::string& path =
"",
560 : m_label(label), m_path(path), m_folder(folder), m_size(size), m_dateTime(dateTime)
575 : m_label(dirEntry.label ? dirEntry.label :
""),
576 m_path(dirEntry.path ? dirEntry.path :
""),
577 m_folder(dirEntry.folder),
578 m_size(dirEntry.size),
579 m_dateTime(dirEntry.date_time)
609 const std::string&
Label(
void)
const {
return m_label; }
617 const std::string&
Title(
void)
const {
return m_title; }
625 const std::string&
Path(
void)
const {
return m_path; }
641 int64_t
Size(
void)
const {
return m_size; }
657 void SetLabel(
const std::string& label) { m_label = label; }
665 void SetTitle(
const std::string& title) { m_title = title; }
673 void SetPath(
const std::string& path) { m_path = path; }
710 void AddProperty(
const std::string&
id,
const std::string& value) { m_properties[id] = value; }
724 const std::map<std::string, std::string>&
GetProperties()
const {
return m_properties; }
733 std::map<std::string, std::string> m_properties;
775 using namespace kodi::addon;
777 return CAddonBase::m_interface->toKodi->kodi_filesystem->create_directory(
778 CAddonBase::m_interface->toKodi->kodiBase, path.c_str());
807 using namespace kodi::addon;
809 return CAddonBase::m_interface->toKodi->kodi_filesystem->directory_exists(
810 CAddonBase::m_interface->toKodi->kodiBase, path.c_str());
839 inline bool ATTRIBUTE_HIDDEN
RemoveDirectory(
const std::string& path,
bool recursive =
false)
841 using namespace kodi::addon;
844 return CAddonBase::m_interface->toKodi->kodi_filesystem->remove_directory(
845 CAddonBase::m_interface->toKodi->kodiBase, path.c_str());
847 return CAddonBase::m_interface->toKodi->kodi_filesystem->remove_directory_recursive(
848 CAddonBase::m_interface->toKodi->kodiBase, path.c_str());
889 const std::string& mask,
890 std::vector<kodi::vfs::CDirEntry>& items)
892 using namespace kodi::addon;
895 unsigned int num_items = 0;
896 if (CAddonBase::m_interface->toKodi->kodi_filesystem->get_directory(
897 CAddonBase::m_interface->toKodi->kodiBase, path.c_str(), mask.c_str(), &dir_list,
902 for (
unsigned int i = 0; i < num_items; ++i)
903 items.emplace_back(dir_list[i]);
905 CAddonBase::m_interface->toKodi->kodi_filesystem->free_directory(
906 CAddonBase::m_interface->toKodi->kodiBase, dir_list, num_items);
940 inline bool ATTRIBUTE_HIDDEN
FileExists(
const std::string& filename,
bool usecache =
false)
942 using namespace kodi::addon;
944 return CAddonBase::m_interface->toKodi->kodi_filesystem->file_exists(
945 CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), usecache);
997 using namespace kodi::addon;
999 return CAddonBase::m_interface->toKodi->kodi_filesystem->stat_file(
1000 CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), buffer);
1033 inline bool ATTRIBUTE_HIDDEN
DeleteFile(
const std::string& filename)
1035 using namespace kodi::addon;
1037 return CAddonBase::m_interface->toKodi->kodi_filesystem->delete_file(
1038 CAddonBase::m_interface->toKodi->kodiBase, filename.c_str());
1051 inline bool ATTRIBUTE_HIDDEN
RenameFile(
const std::string& filename,
const std::string& newFileName)
1053 using namespace kodi::addon;
1055 return CAddonBase::m_interface->toKodi->kodi_filesystem->rename_file(
1056 CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), newFileName.c_str());
1069 inline bool ATTRIBUTE_HIDDEN
CopyFile(
const std::string& filename,
const std::string& destination)
1071 using namespace kodi::addon;
1073 return CAddonBase::m_interface->toKodi->kodi_filesystem->copy_file(
1074 CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), destination.c_str());
1110 inline std::string ATTRIBUTE_HIDDEN
GetFileMD5(
const std::string& path)
1112 using namespace kodi::addon;
1114 std::string strReturn;
1115 char* strMd5 = CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_md5(
1116 CAddonBase::m_interface->toKodi->kodiBase, path.c_str());
1117 if (strMd5 !=
nullptr)
1119 if (std::strlen(strMd5))
1121 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, strMd5);
1155 using namespace kodi::addon;
1157 std::string strReturn;
1158 char* strThumbName = CAddonBase::m_interface->toKodi->kodi_filesystem->get_cache_thumb_name(
1159 CAddonBase::m_interface->toKodi->kodiBase, filename.c_str());
1160 if (strThumbName !=
nullptr)
1162 if (std::strlen(strThumbName))
1163 strReturn = strThumbName;
1164 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
1198 using namespace kodi::addon;
1200 std::string strReturn;
1201 char* strLegalFileName = CAddonBase::m_interface->toKodi->kodi_filesystem->make_legal_filename(
1202 CAddonBase::m_interface->toKodi->kodiBase, filename.c_str());
1203 if (strLegalFileName !=
nullptr)
1205 if (std::strlen(strLegalFileName))
1206 strReturn = strLegalFileName;
1207 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
1241 using namespace kodi::addon;
1243 std::string strReturn;
1244 char* strLegalPath = CAddonBase::m_interface->toKodi->kodi_filesystem->make_legal_path(
1245 CAddonBase::m_interface->toKodi->kodiBase, path.c_str());
1246 if (strLegalPath !=
nullptr)
1248 if (std::strlen(strLegalPath))
1249 strReturn = strLegalPath;
1250 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
1289 using namespace kodi::addon;
1291 std::string strReturn;
1292 char* protocol = CAddonBase::m_interface->toKodi->kodi_filesystem->translate_special_protocol(
1293 CAddonBase::m_interface->toKodi->kodiBase, source.c_str());
1294 if (protocol !=
nullptr)
1296 if (std::strlen(protocol))
1297 strReturn = protocol;
1298 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
1344 uint64_t& available)
1346 using namespace kodi::addon;
1348 return CAddonBase::m_interface->toKodi->kodi_filesystem->get_disk_space(
1349 CAddonBase::m_interface->toKodi->kodiBase, path.c_str(), &capacity, &free, &available);
1371 inline std::string ATTRIBUTE_HIDDEN
GetFileName(
const std::string& path)
1374 const size_t slash = path.find_last_of(
"/\\");
1375 return path.substr(slash + 1);
1402 size_t iPosSlash = path.find_last_of(
"/\\");
1403 if (iPosSlash == std::string::npos)
1406 size_t iPosBar = path.rfind(
'|');
1407 if (iPosBar == std::string::npos)
1408 return path.substr(0, iPosSlash + 1);
1410 return path.substr(0, iPosSlash + 1) + path.substr(iPosBar);
1436 char last = path[path.size() - 1];
1437 if (last ==
'/' || last ==
'\\')
1438 path.erase(path.size() - 1);
1452 inline unsigned int ATTRIBUTE_HIDDEN
GetChunkSize(
unsigned int chunk,
unsigned int minimum)
1455 return chunk * ((minimum + chunk - 1) / chunk);
1509 inline bool ATTRIBUTE_HIDDEN
IsInternetStream(
const std::string& path,
bool strictCheck =
false)
1511 using namespace kodi::addon;
1513 return CAddonBase::m_interface->toKodi->kodi_filesystem->is_internet_stream(
1514 CAddonBase::m_interface->toKodi->kodiBase, path.c_str(), strictCheck);
1541 inline bool ATTRIBUTE_HIDDEN
IsOnLAN(
const std::string& path)
1543 using namespace kodi::addon;
1545 return CAddonBase::m_interface->toKodi->kodi_filesystem->is_on_lan(
1546 CAddonBase::m_interface->toKodi->kodiBase, path.c_str());
1570 inline bool ATTRIBUTE_HIDDEN
IsRemote(
const std::string& path)
1572 using namespace kodi::addon;
1574 return CAddonBase::m_interface->toKodi->kodi_filesystem->is_remote(
1575 CAddonBase::m_interface->toKodi->kodiBase, path.c_str());
1586 inline bool ATTRIBUTE_HIDDEN
IsLocal(
const std::string& path)
1588 using namespace kodi::addon;
1590 return CAddonBase::m_interface->toKodi->kodi_filesystem->is_local(
1591 CAddonBase::m_interface->toKodi->kodiBase, path.c_str());
1617 inline bool ATTRIBUTE_HIDDEN
IsURL(
const std::string& path)
1619 using namespace kodi::addon;
1621 return CAddonBase::m_interface->toKodi->kodi_filesystem->is_url(
1622 CAddonBase::m_interface->toKodi->kodiBase, path.c_str());
1652 using namespace ::kodi::addon;
1654 return CAddonBase::m_interface->toKodi->kodi_filesystem->get_http_header(
1655 CAddonBase::m_interface->toKodi->kodiBase, url.c_str(), &header.m_handle);
1682 std::string& mimeType,
1683 const std::string& useragent =
"")
1685 using namespace ::kodi::addon;
1687 char* cMimeType =
nullptr;
1688 bool ret = CAddonBase::m_interface->toKodi->kodi_filesystem->get_mime_type(
1689 CAddonBase::m_interface->toKodi->kodiBase, url.c_str(), &cMimeType, useragent.c_str());
1690 if (cMimeType !=
nullptr)
1692 mimeType = cMimeType;
1693 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
1723 std::string& content,
1724 const std::string& useragent =
"")
1726 using namespace ::kodi::addon;
1728 char* cContent =
nullptr;
1729 bool ret = CAddonBase::m_interface->toKodi->kodi_filesystem->get_content_type(
1730 CAddonBase::m_interface->toKodi->kodiBase, url.c_str(), &cContent, useragent.c_str());
1731 if (cContent !=
nullptr)
1734 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
1764 inline bool ATTRIBUTE_HIDDEN
GetCookies(
const std::string& url, std::string& cookies)
1766 using namespace ::kodi::addon;
1768 char* cCookies =
nullptr;
1769 bool ret = CAddonBase::m_interface->toKodi->kodi_filesystem->get_cookies(
1770 CAddonBase::m_interface->toKodi->kodiBase, url.c_str(), &cCookies);
1771 if (cCookies !=
nullptr)
1774 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
1855 bool OpenFile(
const std::string& filename,
unsigned int flags = 0)
1857 using namespace kodi::addon;
1860 m_file = CAddonBase::m_interface->toKodi->kodi_filesystem->open_file(
1861 CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), flags);
1862 return m_file !=
nullptr;
1880 using namespace kodi::addon;
1886 m_file = CAddonBase::m_interface->toKodi->kodi_filesystem->open_file_for_write(
1887 CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), overwrite);
1891 if (CAddonBase::m_interface->toKodi->kodi_filesystem->directory_exists(
1892 CAddonBase::m_interface->toKodi->kodiBase, cacheDirectory.c_str()) ||
1893 CAddonBase::m_interface->toKodi->kodi_filesystem->create_directory(
1894 CAddonBase::m_interface->toKodi->kodiBase, cacheDirectory.c_str()))
1895 m_file = CAddonBase::m_interface->toKodi->kodi_filesystem->open_file_for_write(
1896 CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), overwrite);
1898 return m_file !=
nullptr;
1908 bool IsOpen()
const {
return m_file !=
nullptr; }
1917 using namespace kodi::addon;
1921 CAddonBase::m_interface->toKodi->kodi_filesystem->close_file(
1922 CAddonBase::m_interface->toKodi->kodiBase, m_file);
1936 using namespace kodi::addon;
1938 m_file = CAddonBase::m_interface->toKodi->kodi_filesystem->curl_create(
1939 CAddonBase::m_interface->toKodi->kodiBase, url.c_str());
1940 return m_file !=
nullptr;
1955 using namespace kodi::addon;
1962 return CAddonBase::m_interface->toKodi->kodi_filesystem->curl_add_option(
1963 CAddonBase::m_interface->toKodi->kodiBase, m_file, type, name.c_str(), value.c_str());
1976 using namespace kodi::addon;
1983 return CAddonBase::m_interface->toKodi->kodi_filesystem->curl_open(
1984 CAddonBase::m_interface->toKodi->kodiBase, m_file, flags);
1999 ssize_t
Read(
void* ptr,
size_t size)
2001 using namespace kodi::addon;
2005 return CAddonBase::m_interface->toKodi->kodi_filesystem->read_file(
2006 CAddonBase::m_interface->toKodi->kodiBase, m_file, ptr, size);
2019 using namespace kodi::addon;
2028 if (CAddonBase::m_interface->toKodi->kodi_filesystem->read_file_string(
2029 CAddonBase::m_interface->toKodi->kodiBase, m_file, buffer,
sizeof(buffer)))
2032 return !line.empty();
2048 ssize_t
Write(
const void* ptr,
size_t size)
2050 using namespace kodi::addon;
2054 return CAddonBase::m_interface->toKodi->kodi_filesystem->write_file(
2055 CAddonBase::m_interface->toKodi->kodiBase, m_file, ptr, size);
2075 using namespace kodi::addon;
2079 CAddonBase::m_interface->toKodi->kodi_filesystem->flush_file(
2080 CAddonBase::m_interface->toKodi->kodiBase, m_file);
2102 int64_t
Seek(int64_t position,
int whence = SEEK_SET)
2104 using namespace kodi::addon;
2108 return CAddonBase::m_interface->toKodi->kodi_filesystem->seek_file(
2109 CAddonBase::m_interface->toKodi->kodiBase, m_file, position, whence);
2122 using namespace kodi::addon;
2126 return CAddonBase::m_interface->toKodi->kodi_filesystem->truncate_file(
2127 CAddonBase::m_interface->toKodi->kodiBase, m_file, size);
2139 using namespace kodi::addon;
2143 return CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_position(
2144 CAddonBase::m_interface->toKodi->kodiBase, m_file);
2156 using namespace kodi::addon;
2160 return CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_length(
2161 CAddonBase::m_interface->toKodi->kodiBase, m_file);
2173 using namespace kodi::addon;
2177 int64_t length = CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_length(
2178 CAddonBase::m_interface->toKodi->kodiBase, m_file);
2179 int64_t position = CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_position(
2180 CAddonBase::m_interface->toKodi->kodiBase, m_file);
2181 return position >= length;
2193 using namespace kodi::addon;
2197 return CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_chunk_size(
2198 CAddonBase::m_interface->toKodi->kodiBase, m_file);
2210 using namespace kodi::addon;
2214 return CAddonBase::m_interface->toKodi->kodi_filesystem->io_control_get_seek_possible(
2215 CAddonBase::m_interface->toKodi->kodiBase, m_file);
2231 using namespace kodi::addon;
2235 return CAddonBase::m_interface->toKodi->kodi_filesystem->io_control_get_cache_status(
2236 CAddonBase::m_interface->toKodi->kodiBase, m_file, status);
2249 using namespace kodi::addon;
2253 return CAddonBase::m_interface->toKodi->kodi_filesystem->io_control_set_cache_rate(
2254 CAddonBase::m_interface->toKodi->kodiBase, m_file, rate);
2267 using namespace kodi::addon;
2271 return CAddonBase::m_interface->toKodi->kodi_filesystem->io_control_set_retry(
2272 CAddonBase::m_interface->toKodi->kodiBase, m_file, retry);
2286 using namespace kodi::addon;
2291 "kodi::vfs::CURLCreate(...) needed to call before GetPropertyValue!");
2294 std::vector<std::string> values = GetPropertyValues(type, name);
2312 const std::string& name)
const
2314 using namespace kodi::addon;
2319 "kodi::vfs::CURLCreate(...) needed to call before GetPropertyValues!");
2320 return std::vector<std::string>();
2323 char** res(CAddonBase::m_interface->toKodi->kodi_filesystem->get_property_values(
2324 CAddonBase::m_interface->toKodi->kodiBase, m_file, type, name.c_str(), &numValues));
2327 std::vector<std::string> vecReturn;
2328 vecReturn.reserve(numValues);
2329 for (
int i = 0; i < numValues; ++i)
2331 vecReturn.emplace_back(res[i]);
2333 CAddonBase::m_interface->toKodi->free_string_array(CAddonBase::m_interface->toKodi->kodiBase,
2337 return std::vector<std::string>();
2349 using namespace kodi::addon;
2353 return CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_download_speed(
2354 CAddonBase::m_interface->toKodi->kodiBase, m_file);
2359 void* m_file =
nullptr;
Definition: AddonBase.h:250
Definition: Filesystem.h:543
Definition: Filesystem.h:1829
Definition: Filesystem.h:226
Definition: Filesystem.h:96
@ ADDON_LOG_ERROR
3 : To report error messages in the log file.
Definition: addon_base.h:183
void AddProperty(const std::string &id, const std::string &value)
Add a by string defined property entry to directory entry.
Definition: Filesystem.h:710
const std::string & Label(void) const
Get the directory entry name.
Definition: Filesystem.h:609
void SetPath(const std::string &path)
Set the path of the entry.
Definition: Filesystem.h:673
void SetTitle(const std::string &title)
Set the title name.
Definition: Filesystem.h:665
const std::string & Path(void) const
Get the path of the entry.
Definition: Filesystem.h:625
void SetDateTime(time_t dateTime)
Set file time and date for a new entry.
Definition: Filesystem.h:697
const std::string & Title(void) const
Get the optional title of entry.
Definition: Filesystem.h:617
void SetFolder(bool folder)
Set the entry defined as folder.
Definition: Filesystem.h:681
void SetLabel(const std::string &label)
Set the label name.
Definition: Filesystem.h:657
void ClearProperties()
Clear all present properties.
Definition: Filesystem.h:716
time_t DateTime()
Get file time and date for a new entry.
Definition: Filesystem.h:649
bool IsFolder(void) const
Used to check entry is folder.
Definition: Filesystem.h:633
CDirEntry(const std::string &label="", const std::string &path="", bool folder=false, int64_t size=-1, time_t dateTime=0)
Constructor for VFS directory entry.
Definition: Filesystem.h:555
int64_t Size(void) const
If file, the size of the file.
Definition: Filesystem.h:641
void SetSize(int64_t size)
Set a file size for a new entry.
Definition: Filesystem.h:689
const std::map< std::string, std::string > & GetProperties() const
Get the present properties list on directory entry.
Definition: Filesystem.h:724
void Flush()
Flush buffered data.
Definition: Filesystem.h:2073
bool IsOpen() const
Check file is opened.
Definition: Filesystem.h:1908
const std::vector< std::string > GetPropertyValues(FilePropertyTypes type, const std::string &name) const
Retrieve file property values.
Definition: Filesystem.h:2311
bool AtEnd() const
Checks the file access is on end position.
Definition: Filesystem.h:2171
int64_t Seek(int64_t position, int whence=SEEK_SET)
Set the file's current position.
Definition: Filesystem.h:2102
int64_t GetLength() const
Get the file size of an open file.
Definition: Filesystem.h:2154
bool IoControlGetCacheStatus(CacheStatus &status) const
To check a running stream on file for state of his cache.
Definition: Filesystem.h:2229
int GetChunkSize() const
Get the chunk size for an open file.
Definition: Filesystem.h:2191
bool IoControlSetCacheRate(unsigned int rate)
Unsigned int with speed limit for caching in bytes per second.
Definition: Filesystem.h:2247
bool CURLOpen(unsigned int flags=0)
Open the curl file created with CURLCreate.
Definition: Filesystem.h:1974
bool OpenFileForWrite(const std::string &filename, bool overwrite=false)
Open the file with filename via Kodi's CFile in write mode. Needs to be closed by calling Close() whe...
Definition: Filesystem.h:1878
int Truncate(int64_t size)
Truncate a file to the requested size.
Definition: Filesystem.h:2120
void Close()
Close an open file.
Definition: Filesystem.h:1915
bool CURLCreate(const std::string &url)
Create a Curl representation.
Definition: Filesystem.h:1934
bool IoControlGetSeekPossible() const
To check seek possible on current stream by file.
Definition: Filesystem.h:2208
double GetFileDownloadSpeed() const
Get the current download speed of file if loaded from web.
Definition: Filesystem.h:2347
bool OpenFile(const std::string &filename, unsigned int flags=0)
Open the file with filename via Kodi's CFile. Needs to be closed by calling Close() when done.
Definition: Filesystem.h:1855
CFile()=default
Construct a new, unopened file.
virtual ~CFile()
Close() is called from the destructor, so explicitly closing the file isn't required.
Definition: Filesystem.h:1843
ssize_t Write(const void *ptr, size_t size)
Write to a file opened in write mode.
Definition: Filesystem.h:2048
bool CURLAddOption(CURLOptiontype type, const std::string &name, const std::string &value)
Add options to the curl file created with CURLCreate.
Definition: Filesystem.h:1953
bool IoControlSetRetry(bool retry)
Enable/disable retry within the protocol handler (if supported).
Definition: Filesystem.h:2265
bool ReadLine(std::string &line)
Read a string from an open file.
Definition: Filesystem.h:2017
const std::string GetPropertyValue(FilePropertyTypes type, const std::string &name) const
Retrieve a file property.
Definition: Filesystem.h:2284
int64_t GetPosition() const
The current offset in an open file.
Definition: Filesystem.h:2137
ssize_t Read(void *ptr, size_t size)
Read from an open file.
Definition: Filesystem.h:1999
CURLOptiontype
Definition: filesystem.h:109
void SetMaxRate(unsigned int maxrate)
Set maximum number of bytes per second cache is allowed to fill.
Definition: Filesystem.h:259
void SetCurrentRate(unsigned int currate)
Set average read rate from source file since last position change.
Definition: Filesystem.h:265
unsigned int GetMaxRate()
Set maximum number of bytes per second cache is allowed to fill.
Definition: Filesystem.h:262
void SetLowspeed(bool lowspeed)
Set cache low speed condition detected.
Definition: Filesystem.h:271
bool GetLowspeed()
Get cache low speed condition detected.
Definition: Filesystem.h:274
unsigned int GetCurrentRate()
Get average read rate from source file since last position change.
Definition: Filesystem.h:268
void SetForward(uint64_t forward)
Set number of bytes cached forward of current position.
Definition: Filesystem.h:253
uint64_t GetForward()
Get number of bytes cached forward of current position.
Definition: Filesystem.h:256
FilePropertyTypes
Definition: filesystem.h:153
bool GetIsRegular() const
Get stat url is a regular.
Definition: Filesystem.h:204
uint64_t GetSize() const
Get total size, in bytes.
Definition: Filesystem.h:147
bool GetIsBlock() const
Get stat url is a block special.
Definition: Filesystem.h:186
bool GetIsSocket() const
Get stat url is a regular.
Definition: Filesystem.h:210
void SetIsBlock(bool isBlock)
Set stat url as a block special.
Definition: Filesystem.h:183
void SetIsFifo(bool isFifo)
Set stat url as a FIFO special.
Definition: Filesystem.h:195
void SetIsDirectory(bool isDirectory)
Set the stat url is a directory.
Definition: Filesystem.h:171
time_t GetAccessTime() const
Get time of last access.
Definition: Filesystem.h:153
void SetStatusTime(time_t statusTime)
Set time of last status change.
Definition: Filesystem.h:165
bool GetIsDirectory() const
The stat url is a directory if returns true.
Definition: Filesystem.h:174
void SetDeviceId(uint32_t deviceId)
Set ID of device containing file.
Definition: Filesystem.h:132
bool GetIsSymLink() const
Get stat url is a symbolic link.
Definition: Filesystem.h:180
bool GetIsFifo() const
Get stat url is a FIFO special.
Definition: Filesystem.h:198
bool GetIsCharacter() const
Get stat url is a character special.
Definition: Filesystem.h:192
uint32_t GetDeviceId() const
Get ID of device containing file.
Definition: Filesystem.h:135
void SetModificationTime(time_t modificationTime)
Set time of last modification.
Definition: Filesystem.h:156
void SetAccessTime(time_t accessTime)
Set time of last access.
Definition: Filesystem.h:150
void SetSize(uint64_t size)
Set total size, in bytes.
Definition: Filesystem.h:144
time_t GetModificationTime() const
Get time of last modification.
Definition: Filesystem.h:162
void SetIsCharacter(bool isCharacter)
Set stat url as a character special.
Definition: Filesystem.h:189
void SetIsSocket(bool isSocket)
Set stat url is a socket.
Definition: Filesystem.h:207
void SetFileSerialNumber(uint64_t fileSerialNumber)
Set the file serial number, which distinguishes this file from all other files on the same device.
Definition: Filesystem.h:138
time_t GetStatusTime() const
Get time of last status change.
Definition: Filesystem.h:168
uint64_t GetFileSerialNumber() const
Get the file serial number, which distinguishes this file from all other files on the same device.
Definition: Filesystem.h:141
void SetIsRegular(bool isRegular)
Set stat url as a regular.
Definition: Filesystem.h:201
void SetIsSymLink(bool isSymLink)
Set stat url as a symbolic link.
Definition: Filesystem.h:177
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
bool ATTRIBUTE_HIDDEN DeleteFile(const std::string &filename)
Deletes a file.
Definition: Filesystem.h:1033
bool ATTRIBUTE_HIDDEN StatFile(const std::string &filename, kodi::vfs::FileStatus &buffer)
Get file status.
Definition: Filesystem.h:995
bool ATTRIBUTE_HIDDEN RenameFile(const std::string &filename, const std::string &newFileName)
Rename a file name.
Definition: Filesystem.h:1051
bool ATTRIBUTE_HIDDEN FileExists(const std::string &filename, bool usecache=false)
Check if a file exists.
Definition: Filesystem.h:940
bool ATTRIBUTE_HIDDEN CopyFile(const std::string &filename, const std::string &destination)
Copy a file from source to destination.
Definition: Filesystem.h:1069
std::string ATTRIBUTE_HIDDEN TranslateSpecialProtocol(const std::string &source)
Returns the translated path.
Definition: Filesystem.h:1287
std::string ATTRIBUTE_HIDDEN MakeLegalFileName(const std::string &filename)
Make filename valid.
Definition: Filesystem.h:1196
bool ATTRIBUTE_HIDDEN GetContentType(const std::string &url, std::string &content, const std::string &useragent="")
Get file content-type.
Definition: Filesystem.h:1722
std::string ATTRIBUTE_HIDDEN GetFileName(const std::string &path)
Return the file name from given complate path string.
Definition: Filesystem.h:1371
bool ATTRIBUTE_HIDDEN IsInternetStream(const std::string &path, bool strictCheck=false)
Checks the given path contains a known internet protocol.
Definition: Filesystem.h:1509
bool ATTRIBUTE_HIDDEN GetHttpHeader(const std::string &url, HttpHeader &header)
To get HTTP header information.
Definition: Filesystem.h:1650
std::string ATTRIBUTE_HIDDEN MakeLegalPath(const std::string &path)
Make directory name valid.
Definition: Filesystem.h:1239
bool ATTRIBUTE_HIDDEN GetMimeType(const std::string &url, std::string &mimeType, const std::string &useragent="")
Get file mime type.
Definition: Filesystem.h:1681
void ATTRIBUTE_HIDDEN RemoveSlashAtEnd(std::string &path)
Remove the slash on given path name.
Definition: Filesystem.h:1432
std::string ATTRIBUTE_HIDDEN GetFileMD5(const std::string &path)
Retrieve MD5sum of a file.
Definition: Filesystem.h:1110
std::string ATTRIBUTE_HIDDEN GetDirectoryName(const std::string &path)
Return the directory name from given complate path string.
Definition: Filesystem.h:1397
bool ATTRIBUTE_HIDDEN IsURL(const std::string &path)
Checks specified path is a regular URL, e.g. "someprotocol://path/to/file".
Definition: Filesystem.h:1617
bool ATTRIBUTE_HIDDEN IsOnLAN(const std::string &path)
Checks whether the specified path refers to a local network.
Definition: Filesystem.h:1541
bool ATTRIBUTE_HIDDEN GetDiskSpace(const std::string &path, uint64_t &capacity, uint64_t &free, uint64_t &available)
Retrieves information about the amount of space that is available on a disk volume.
Definition: Filesystem.h:1341
bool ATTRIBUTE_HIDDEN GetCookies(const std::string &url, std::string &cookies)
Get cookies stored by CURL in RFC 2109 format.
Definition: Filesystem.h:1764
std::string ATTRIBUTE_HIDDEN GetCacheThumbName(const std::string &filename)
Returns a thumb cache filename.
Definition: Filesystem.h:1153
bool ATTRIBUTE_HIDDEN IsRemote(const std::string &path)
Checks specified path for external network.
Definition: Filesystem.h:1570
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
bool ATTRIBUTE_HIDDEN IsLocal(const std::string &path)
Checks whether the given path refers to the own system.
Definition: Filesystem.h:1586
void ATTRIBUTE_HIDDEN Log(const AddonLog loglevel, const char *format,...)
Add a message to Kodi's log.
Definition: AddonBase.h:749
Definition: filesystem.h:177
Definition: filesystem.h:189
Definition: filesystem.h:220
Definition: filesystem.h:234