12#include "c-api/filesystem.h"
132 void SetDeviceId(uint32_t deviceId) { m_cStructure->deviceId = deviceId; }
140 m_cStructure->fileSerialNumber = fileSerialNumber;
147 void SetSize(uint64_t size) { m_cStructure->size = size; }
150 uint64_t
GetSize()
const {
return m_cStructure->size; }
153 void SetAccessTime(time_t accessTime) { m_cStructure->accessTime = accessTime; }
161 m_cStructure->modificationTime = modificationTime;
168 void SetStatusTime(time_t statusTime) { m_cStructure->statusTime = statusTime; }
174 void SetIsDirectory(
bool isDirectory) { m_cStructure->isDirectory = isDirectory; }
180 void SetIsSymLink(
bool isSymLink) { m_cStructure->isSymLink = isSymLink; }
186 void SetIsBlock(
bool isBlock) { m_cStructure->isBlock = isBlock; }
192 void SetIsCharacter(
bool isCharacter) { m_cStructure->isCharacter = isCharacter; }
198 void SetIsFifo(
bool isFifo) { m_cStructure->isFifo = isFifo; }
204 void SetIsRegular(
bool isRegular) { m_cStructure->isRegular = isRegular; }
210 void SetIsSocket(
bool isSocket) { m_cStructure->isSocket = isSocket; }
256 void SetForward(uint64_t forward) { m_cStructure->forward = forward; }
262 void SetMaxRate(uint32_t maxrate) { m_cStructure->maxrate = maxrate; }
274 void SetLowRate(uint32_t lowrate) { m_cStructure->lowrate = lowrate; }
305 using namespace ::kodi::addon;
307 CPrivateBase::m_interface->toKodi->kodi_filesystem->http_header_create(
308 CPrivateBase::m_interface->toKodi->kodiBase, &m_handle);
317 using namespace ::kodi::addon;
319 CPrivateBase::m_interface->toKodi->kodi_filesystem->http_header_free(
320 CPrivateBase::m_interface->toKodi->kodiBase, &m_handle);
348 std::string
GetValue(
const std::string& param)
const
350 using namespace ::kodi::addon;
352 if (!m_handle.handle)
355 std::string protoLine;
356 char*
string = m_handle.get_value(CPrivateBase::m_interface->toKodi->kodiBase, m_handle.handle,
358 if (
string !=
nullptr)
361 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
375 std::vector<std::string>
GetValues(
const std::string& param)
const
377 using namespace kodi::addon;
379 if (!m_handle.handle)
380 return std::vector<std::string>();
383 char** res(m_handle.get_values(CPrivateBase::m_interface->toKodi->kodiBase, m_handle.handle,
384 param.c_str(), &numValues));
387 std::vector<std::string> vecReturn;
388 vecReturn.reserve(numValues);
389 for (
int i = 0; i < numValues; ++i)
391 vecReturn.emplace_back(res[i]);
393 CPrivateBase::m_interface->toKodi->free_string_array(
394 CPrivateBase::m_interface->toKodi->kodiBase, res, numValues);
397 return std::vector<std::string>();
408 using namespace ::kodi::addon;
410 if (!m_handle.handle)
415 m_handle.get_header(CPrivateBase::m_interface->toKodi->kodiBase, m_handle.handle);
416 if (
string !=
nullptr)
419 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
433 using namespace ::kodi::addon;
435 if (!m_handle.handle)
438 std::string protoLine;
440 m_handle.get_mime_type(CPrivateBase::m_interface->toKodi->kodiBase, m_handle.handle);
441 if (
string !=
nullptr)
444 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
458 using namespace ::kodi::addon;
460 if (!m_handle.handle)
463 std::string protoLine;
465 m_handle.get_charset(CPrivateBase::m_interface->toKodi->kodiBase, m_handle.handle);
466 if (
string !=
nullptr)
469 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
483 using namespace ::kodi::addon;
485 if (!m_handle.handle)
488 std::string protoLine;
490 m_handle.get_proto_line(CPrivateBase::m_interface->toKodi->kodiBase, m_handle.handle);
491 if (
string !=
nullptr)
494 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
561 const std::string& path =
"",
584 : m_label(dirEntry.label ? dirEntry.label :
""),
585 m_path(dirEntry.path ? dirEntry.path :
""),
586 m_folder(dirEntry.folder),
587 m_size(dirEntry.size),
588 m_dateTime(dirEntry.date_time)
618 const std::string&
Label(
void)
const {
return m_label; }
626 const std::string&
Title(
void)
const {
return m_title; }
634 const std::string&
Path(
void)
const {
return m_path; }
650 int64_t
Size(
void)
const {
return m_size; }
666 void SetLabel(
const std::string& label) { m_label = label; }
674 void SetTitle(
const std::string& title) { m_title = title; }
682 void SetPath(
const std::string& path) { m_path = path; }
719 void AddProperty(
const std::string&
id,
const std::string& value) { m_properties[id] = value; }
733 const std::map<std::string, std::string>&
GetProperties()
const {
return m_properties; }
742 std::map<std::string, std::string> m_properties;
784 using namespace kodi::addon;
786 return CPrivateBase::m_interface->toKodi->kodi_filesystem->create_directory(
787 CPrivateBase::m_interface->toKodi->kodiBase, path.c_str());
816 using namespace kodi::addon;
818 return CPrivateBase::m_interface->toKodi->kodi_filesystem->directory_exists(
819 CPrivateBase::m_interface->toKodi->kodiBase, path.c_str());
848inline bool ATTR_DLL_LOCAL
RemoveDirectory(
const std::string& path,
bool recursive =
false)
850 using namespace kodi::addon;
853 return CPrivateBase::m_interface->toKodi->kodi_filesystem->remove_directory(
854 CPrivateBase::m_interface->toKodi->kodiBase, path.c_str());
856 return CPrivateBase::m_interface->toKodi->kodi_filesystem->remove_directory_recursive(
857 CPrivateBase::m_interface->toKodi->kodiBase, path.c_str());
898 const std::string& mask,
899 std::vector<kodi::vfs::CDirEntry>& items)
901 using namespace kodi::addon;
904 unsigned int num_items = 0;
905 if (CPrivateBase::m_interface->toKodi->kodi_filesystem->get_directory(
906 CPrivateBase::m_interface->toKodi->kodiBase, path.c_str(), mask.c_str(), &dir_list,
911 for (
unsigned int i = 0; i < num_items; ++i)
912 items.emplace_back(dir_list[i]);
914 CPrivateBase::m_interface->toKodi->kodi_filesystem->free_directory(
915 CPrivateBase::m_interface->toKodi->kodiBase, dir_list, num_items);
949inline bool ATTR_DLL_LOCAL
FileExists(
const std::string& filename,
bool usecache =
false)
951 using namespace kodi::addon;
953 return CPrivateBase::m_interface->toKodi->kodi_filesystem->file_exists(
954 CPrivateBase::m_interface->toKodi->kodiBase, filename.c_str(), usecache);
1006 using namespace kodi::addon;
1008 return CPrivateBase::m_interface->toKodi->kodi_filesystem->stat_file(
1009 CPrivateBase::m_interface->toKodi->kodiBase, filename.c_str(), buffer);
1042inline bool ATTR_DLL_LOCAL
DeleteFile(
const std::string& filename)
1044 using namespace kodi::addon;
1046 return CPrivateBase::m_interface->toKodi->kodi_filesystem->delete_file(
1047 CPrivateBase::m_interface->toKodi->kodiBase, filename.c_str());
1060inline bool ATTR_DLL_LOCAL
RenameFile(
const std::string& filename,
const std::string& newFileName)
1062 using namespace kodi::addon;
1064 return CPrivateBase::m_interface->toKodi->kodi_filesystem->rename_file(
1065 CPrivateBase::m_interface->toKodi->kodiBase, filename.c_str(), newFileName.c_str());
1078inline bool ATTR_DLL_LOCAL
CopyFile(
const std::string& filename,
const std::string& destination)
1080 using namespace kodi::addon;
1082 return CPrivateBase::m_interface->toKodi->kodi_filesystem->copy_file(
1083 CPrivateBase::m_interface->toKodi->kodiBase, filename.c_str(), destination.c_str());
1119inline std::string ATTR_DLL_LOCAL
GetFileMD5(
const std::string& path)
1121 using namespace kodi::addon;
1123 std::string strReturn;
1124 char* strMd5 = CPrivateBase::m_interface->toKodi->kodi_filesystem->get_file_md5(
1125 CPrivateBase::m_interface->toKodi->kodiBase, path.c_str());
1126 if (strMd5 !=
nullptr)
1128 if (std::strlen(strMd5))
1130 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
1165 using namespace kodi::addon;
1167 std::string strReturn;
1168 char* strThumbName = CPrivateBase::m_interface->toKodi->kodi_filesystem->get_cache_thumb_name(
1169 CPrivateBase::m_interface->toKodi->kodiBase, filename.c_str());
1170 if (strThumbName !=
nullptr)
1172 if (std::strlen(strThumbName))
1173 strReturn = strThumbName;
1174 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
1208 using namespace kodi::addon;
1210 std::string strReturn;
1211 char* strLegalFileName = CPrivateBase::m_interface->toKodi->kodi_filesystem->make_legal_filename(
1212 CPrivateBase::m_interface->toKodi->kodiBase, filename.c_str());
1213 if (strLegalFileName !=
nullptr)
1215 if (std::strlen(strLegalFileName))
1216 strReturn = strLegalFileName;
1217 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
1251 using namespace kodi::addon;
1253 std::string strReturn;
1254 char* strLegalPath = CPrivateBase::m_interface->toKodi->kodi_filesystem->make_legal_path(
1255 CPrivateBase::m_interface->toKodi->kodiBase, path.c_str());
1256 if (strLegalPath !=
nullptr)
1258 if (std::strlen(strLegalPath))
1259 strReturn = strLegalPath;
1260 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
1299 using namespace kodi::addon;
1301 std::string strReturn;
1302 char* protocol = CPrivateBase::m_interface->toKodi->kodi_filesystem->translate_special_protocol(
1303 CPrivateBase::m_interface->toKodi->kodiBase, source.c_str());
1304 if (protocol !=
nullptr)
1306 if (std::strlen(protocol))
1307 strReturn = protocol;
1308 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
1354 uint64_t& available)
1356 using namespace kodi::addon;
1358 return CPrivateBase::m_interface->toKodi->kodi_filesystem->get_disk_space(
1359 CPrivateBase::m_interface->toKodi->kodiBase, path.c_str(), &capacity, &free, &available);
1384 const size_t slash = path.find_last_of(
"/\\");
1385 return path.substr(slash + 1);
1412 size_t iPosSlash = path.find_last_of(
"/\\");
1413 if (iPosSlash == std::string::npos)
1416 size_t iPosBar = path.rfind(
'|');
1417 if (iPosBar == std::string::npos)
1418 return path.substr(0, iPosSlash + 1);
1420 return path.substr(0, iPosSlash + 1) + path.substr(iPosBar);
1446 char last = path[path.size() - 1];
1447 if (last ==
'/' || last ==
'\\')
1448 path.erase(path.size() - 1);
1462inline unsigned int ATTR_DLL_LOCAL
GetChunkSize(
unsigned int chunk,
unsigned int minimum)
1465 return chunk * ((minimum + chunk - 1) / chunk);
1521 using namespace kodi::addon;
1523 return CPrivateBase::m_interface->toKodi->kodi_filesystem->is_internet_stream(
1524 CPrivateBase::m_interface->toKodi->kodiBase, path.c_str(), strictCheck);
1551inline bool ATTR_DLL_LOCAL
IsOnLAN(
const std::string& path)
1553 using namespace kodi::addon;
1555 return CPrivateBase::m_interface->toKodi->kodi_filesystem->is_on_lan(
1556 CPrivateBase::m_interface->toKodi->kodiBase, path.c_str());
1580inline bool ATTR_DLL_LOCAL
IsRemote(
const std::string& path)
1582 using namespace kodi::addon;
1584 return CPrivateBase::m_interface->toKodi->kodi_filesystem->is_remote(
1585 CPrivateBase::m_interface->toKodi->kodiBase, path.c_str());
1596inline bool ATTR_DLL_LOCAL
IsLocal(
const std::string& path)
1598 using namespace kodi::addon;
1600 return CPrivateBase::m_interface->toKodi->kodi_filesystem->is_local(
1601 CPrivateBase::m_interface->toKodi->kodiBase, path.c_str());
1627inline bool ATTR_DLL_LOCAL
IsURL(
const std::string& path)
1629 using namespace kodi::addon;
1631 return CPrivateBase::m_interface->toKodi->kodi_filesystem->is_url(
1632 CPrivateBase::m_interface->toKodi->kodiBase, path.c_str());
1662 using namespace ::kodi::addon;
1664 return CPrivateBase::m_interface->toKodi->kodi_filesystem->get_http_header(
1665 CPrivateBase::m_interface->toKodi->kodiBase, url.c_str(), &header.m_handle);
1692 std::string& mimeType,
1693 const std::string& useragent =
"")
1695 using namespace ::kodi::addon;
1697 char* cMimeType =
nullptr;
1698 bool ret = CPrivateBase::m_interface->toKodi->kodi_filesystem->get_mime_type(
1699 CPrivateBase::m_interface->toKodi->kodiBase, url.c_str(), &cMimeType, useragent.c_str());
1700 if (cMimeType !=
nullptr)
1702 mimeType = cMimeType;
1703 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
1733 std::string& content,
1734 const std::string& useragent =
"")
1736 using namespace ::kodi::addon;
1738 char* cContent =
nullptr;
1739 bool ret = CPrivateBase::m_interface->toKodi->kodi_filesystem->get_content_type(
1740 CPrivateBase::m_interface->toKodi->kodiBase, url.c_str(), &cContent, useragent.c_str());
1741 if (cContent !=
nullptr)
1744 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
1774inline bool ATTR_DLL_LOCAL
GetCookies(
const std::string& url, std::string& cookies)
1776 using namespace ::kodi::addon;
1778 char* cCookies =
nullptr;
1779 bool ret = CPrivateBase::m_interface->toKodi->kodi_filesystem->get_cookies(
1780 CPrivateBase::m_interface->toKodi->kodiBase, url.c_str(), &cCookies);
1781 if (cCookies !=
nullptr)
1784 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
1865 bool OpenFile(
const std::string& filename,
unsigned int flags = 0)
1867 using namespace kodi::addon;
1870 m_file = CPrivateBase::m_interface->toKodi->kodi_filesystem->open_file(
1871 CPrivateBase::m_interface->toKodi->kodiBase, filename.c_str(), flags);
1872 return m_file !=
nullptr;
1890 using namespace kodi::addon;
1896 m_file = CPrivateBase::m_interface->toKodi->kodi_filesystem->open_file_for_write(
1897 CPrivateBase::m_interface->toKodi->kodiBase, filename.c_str(), overwrite);
1901 if (CPrivateBase::m_interface->toKodi->kodi_filesystem->directory_exists(
1902 CPrivateBase::m_interface->toKodi->kodiBase, cacheDirectory.c_str()) ||
1903 CPrivateBase::m_interface->toKodi->kodi_filesystem->create_directory(
1904 CPrivateBase::m_interface->toKodi->kodiBase, cacheDirectory.c_str()))
1905 m_file = CPrivateBase::m_interface->toKodi->kodi_filesystem->open_file_for_write(
1906 CPrivateBase::m_interface->toKodi->kodiBase, filename.c_str(), overwrite);
1908 return m_file !=
nullptr;
1918 bool IsOpen()
const {
return m_file !=
nullptr; }
1927 using namespace kodi::addon;
1931 CPrivateBase::m_interface->toKodi->kodi_filesystem->close_file(
1932 CPrivateBase::m_interface->toKodi->kodiBase, m_file);
1946 using namespace kodi::addon;
1948 m_file = CPrivateBase::m_interface->toKodi->kodi_filesystem->curl_create(
1949 CPrivateBase::m_interface->toKodi->kodiBase, url.c_str());
1950 return m_file !=
nullptr;
1965 using namespace kodi::addon;
1972 return CPrivateBase::m_interface->toKodi->kodi_filesystem->curl_add_option(
1973 CPrivateBase::m_interface->toKodi->kodiBase, m_file, type, name.c_str(), value.c_str());
1986 using namespace kodi::addon;
1993 return CPrivateBase::m_interface->toKodi->kodi_filesystem->curl_open(
1994 CPrivateBase::m_interface->toKodi->kodiBase, m_file, flags);
2009 ssize_t
Read(
void* ptr,
size_t size)
2011 using namespace kodi::addon;
2015 return CPrivateBase::m_interface->toKodi->kodi_filesystem->read_file(
2016 CPrivateBase::m_interface->toKodi->kodiBase, m_file, ptr, size);
2055 using namespace kodi::addon;
2070 char buffer[1025]{};
2071 if (CPrivateBase::m_interface->toKodi->kodi_filesystem->read_file_string(
2072 CPrivateBase::m_interface->toKodi->kodiBase, m_file, buffer,
sizeof(buffer) - 1))
2075 return !line.empty();
2091 ssize_t
Write(
const void* ptr,
size_t size)
2093 using namespace kodi::addon;
2097 return CPrivateBase::m_interface->toKodi->kodi_filesystem->write_file(
2098 CPrivateBase::m_interface->toKodi->kodiBase, m_file, ptr, size);
2118 using namespace kodi::addon;
2122 CPrivateBase::m_interface->toKodi->kodi_filesystem->flush_file(
2123 CPrivateBase::m_interface->toKodi->kodiBase, m_file);
2145 int64_t
Seek(int64_t position,
int whence = SEEK_SET)
2147 using namespace kodi::addon;
2151 return CPrivateBase::m_interface->toKodi->kodi_filesystem->seek_file(
2152 CPrivateBase::m_interface->toKodi->kodiBase, m_file, position, whence);
2165 using namespace kodi::addon;
2169 return CPrivateBase::m_interface->toKodi->kodi_filesystem->truncate_file(
2170 CPrivateBase::m_interface->toKodi->kodiBase, m_file, size);
2182 using namespace kodi::addon;
2186 return CPrivateBase::m_interface->toKodi->kodi_filesystem->get_file_position(
2187 CPrivateBase::m_interface->toKodi->kodiBase, m_file);
2199 using namespace kodi::addon;
2203 return CPrivateBase::m_interface->toKodi->kodi_filesystem->get_file_length(
2204 CPrivateBase::m_interface->toKodi->kodiBase, m_file);
2216 using namespace kodi::addon;
2220 int64_t length = CPrivateBase::m_interface->toKodi->kodi_filesystem->get_file_length(
2221 CPrivateBase::m_interface->toKodi->kodiBase, m_file);
2222 int64_t position = CPrivateBase::m_interface->toKodi->kodi_filesystem->get_file_position(
2223 CPrivateBase::m_interface->toKodi->kodiBase, m_file);
2224 return position >= length;
2236 using namespace kodi::addon;
2240 return CPrivateBase::m_interface->toKodi->kodi_filesystem->get_file_chunk_size(
2241 CPrivateBase::m_interface->toKodi->kodiBase, m_file);
2253 using namespace kodi::addon;
2257 return CPrivateBase::m_interface->toKodi->kodi_filesystem->io_control_get_seek_possible(
2258 CPrivateBase::m_interface->toKodi->kodiBase, m_file);
2274 using namespace kodi::addon;
2278 return CPrivateBase::m_interface->toKodi->kodi_filesystem->io_control_get_cache_status(
2279 CPrivateBase::m_interface->toKodi->kodiBase, m_file, status);
2292 using namespace kodi::addon;
2296 return CPrivateBase::m_interface->toKodi->kodi_filesystem->io_control_set_cache_rate(
2297 CPrivateBase::m_interface->toKodi->kodiBase, m_file, rate);
2310 using namespace kodi::addon;
2314 return CPrivateBase::m_interface->toKodi->kodi_filesystem->io_control_set_retry(
2315 CPrivateBase::m_interface->toKodi->kodiBase, m_file, retry);
2329 using namespace kodi::addon;
2334 "kodi::vfs::CURLCreate(...) needed to call before GetPropertyValue!");
2337 std::vector<std::string> values = GetPropertyValues(type, name);
2355 const std::string& name)
const
2357 using namespace kodi::addon;
2362 "kodi::vfs::CURLCreate(...) needed to call before GetPropertyValues!");
2363 return std::vector<std::string>();
2366 char** res(CPrivateBase::m_interface->toKodi->kodi_filesystem->get_property_values(
2367 CPrivateBase::m_interface->toKodi->kodiBase, m_file, type, name.c_str(), &numValues));
2370 std::vector<std::string> vecReturn;
2371 vecReturn.reserve(numValues);
2372 for (
int i = 0; i < numValues; ++i)
2374 vecReturn.emplace_back(res[i]);
2376 CPrivateBase::m_interface->toKodi->free_string_array(
2377 CPrivateBase::m_interface->toKodi->kodiBase, res, numValues);
2380 return std::vector<std::string>();
2392 using namespace kodi::addon;
2396 return CPrivateBase::m_interface->toKodi->kodi_filesystem->get_file_download_speed(
2397 CPrivateBase::m_interface->toKodi->kodiBase, m_file);
2402 void* m_file =
nullptr;
Definition AddonBase.h:206
Definition Filesystem.h:548
Definition Filesystem.h:1839
Definition Filesystem.h:229
Definition Filesystem.h:96
@ ADDON_LOG_ERROR
3 : To report error messages in the log file.
Definition addon_base.h:193
void AddProperty(const std::string &id, const std::string &value)
Add a by string defined property entry to directory entry.
Definition Filesystem.h:719
const std::map< std::string, std::string > & GetProperties() const
Get the present properties list on directory entry.
Definition Filesystem.h:733
void SetPath(const std::string &path)
Set the path of the entry.
Definition Filesystem.h:682
void SetTitle(const std::string &title)
Set the title name.
Definition Filesystem.h:674
const std::string & Path(void) const
Get the path of the entry.
Definition Filesystem.h:634
void SetDateTime(time_t dateTime)
Set file time and date for a new entry.
Definition Filesystem.h:706
void SetFolder(bool folder)
Set the entry defined as folder.
Definition Filesystem.h:690
void SetLabel(const std::string &label)
Set the label name.
Definition Filesystem.h:666
void ClearProperties()
Clear all present properties.
Definition Filesystem.h:725
time_t DateTime()
Get file time and date for a new entry.
Definition Filesystem.h:658
const std::string & Title(void) const
Get the optional title of entry.
Definition Filesystem.h:626
bool IsFolder(void) const
Used to check entry is folder.
Definition Filesystem.h:642
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:560
int64_t Size(void) const
If file, the size of the file.
Definition Filesystem.h:650
const std::string & Label(void) const
Get the directory entry name.
Definition Filesystem.h:618
void SetSize(int64_t size)
Set a file size for a new entry.
Definition Filesystem.h:698
void Flush()
Flush buffered data.
Definition Filesystem.h:2116
bool IsOpen() const
Check file is opened.
Definition Filesystem.h:1918
bool IoControlSetCacheRate(uint32_t rate)
Unsigned int with speed limit for caching in bytes per second.
Definition Filesystem.h:2290
bool AtEnd() const
Checks the file access is on end position.
Definition Filesystem.h:2214
int64_t Seek(int64_t position, int whence=SEEK_SET)
Set the file's current position.
Definition Filesystem.h:2145
int64_t GetLength() const
Get the file size of an open file.
Definition Filesystem.h:2197
bool IoControlGetCacheStatus(CacheStatus &status) const
To check a running stream on file for state of his cache.
Definition Filesystem.h:2272
int GetChunkSize() const
Get the chunk size for an open file.
Definition Filesystem.h:2234
bool CURLOpen(unsigned int flags=0)
Open the curl file created with CURLCreate.
Definition Filesystem.h:1984
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:1888
int Truncate(int64_t size)
Truncate a file to the requested size.
Definition Filesystem.h:2163
void Close()
Close an open file.
Definition Filesystem.h:1925
bool CURLCreate(const std::string &url)
Create a Curl representation.
Definition Filesystem.h:1944
bool IoControlGetSeekPossible() const
To check seek possible on current stream by file.
Definition Filesystem.h:2251
double GetFileDownloadSpeed() const
Get the current download speed of file if loaded from web.
Definition Filesystem.h:2390
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:1865
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:1853
const std::vector< std::string > GetPropertyValues(FilePropertyTypes type, const std::string &name) const
Retrieve file property values.
Definition Filesystem.h:2354
ssize_t Write(const void *ptr, size_t size)
Write to a file opened in write mode.
Definition Filesystem.h:2091
bool CURLAddOption(CURLOptiontype type, const std::string &name, const std::string &value)
Add options to the curl file created with CURLCreate.
Definition Filesystem.h:1963
bool IoControlSetRetry(bool retry)
Enable/disable retry within the protocol handler (if supported).
Definition Filesystem.h:2308
bool ReadLine(std::string &line)
Read a string from an open file.
Definition Filesystem.h:2053
const std::string GetPropertyValue(FilePropertyTypes type, const std::string &name) const
Retrieve a file property.
Definition Filesystem.h:2327
int64_t GetPosition() const
The current offset in an open file.
Definition Filesystem.h:2180
ssize_t Read(void *ptr, size_t size)
Read from an open file.
Definition Filesystem.h:2009
CURLOptiontype
Definition filesystem.h:117
uint32_t GetMaxRate()
Set maximum number of bytes per second cache is allowed to fill.
Definition Filesystem.h:265
uint32_t GetLowRate()
Get number of bytes per second for low speed rate.
Definition Filesystem.h:277
void SetMaxRate(uint32_t maxrate)
Set maximum number of bytes per second cache is allowed to fill.
Definition Filesystem.h:262
void SetCurrentRate(uint32_t currate)
Set number of bytes per second for 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:256
uint32_t GetCurrentRate()
Get number of bytes per second for average read rate from source file since last position change.
Definition Filesystem.h:271
void SetLowRate(uint32_t lowrate)
Set number of bytes per second for low speed rate.
Definition Filesystem.h:274
uint64_t GetForward()
Get number of bytes cached forward of current position.
Definition Filesystem.h:259
FilePropertyTypes
Definition filesystem.h:162
bool GetIsRegular() const
Get stat url is a regular.
Definition Filesystem.h:207
uint64_t GetSize() const
Get total size, in bytes.
Definition Filesystem.h:150
bool GetIsBlock() const
Get stat url is a block special.
Definition Filesystem.h:189
bool GetIsSocket() const
Get stat url is a regular.
Definition Filesystem.h:213
void SetIsBlock(bool isBlock)
Set stat url as a block special.
Definition Filesystem.h:186
void SetIsFifo(bool isFifo)
Set stat url as a FIFO special.
Definition Filesystem.h:198
void SetIsDirectory(bool isDirectory)
Set the stat url is a directory.
Definition Filesystem.h:174
time_t GetAccessTime() const
Get time of last access.
Definition Filesystem.h:156
void SetStatusTime(time_t statusTime)
Set time of last status change.
Definition Filesystem.h:168
bool GetIsDirectory() const
The stat url is a directory if returns true.
Definition Filesystem.h:177
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:183
bool GetIsFifo() const
Get stat url is a FIFO special.
Definition Filesystem.h:201
bool GetIsCharacter() const
Get stat url is a character special.
Definition Filesystem.h:195
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:159
void SetAccessTime(time_t accessTime)
Set time of last access.
Definition Filesystem.h:153
void SetSize(uint64_t size)
Set total size, in bytes.
Definition Filesystem.h:147
time_t GetModificationTime() const
Get time of last modification.
Definition Filesystem.h:165
void SetIsCharacter(bool isCharacter)
Set stat url as a character special.
Definition Filesystem.h:192
void SetIsSocket(bool isSocket)
Set stat url is a socket.
Definition Filesystem.h:210
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:171
uint64_t GetFileSerialNumber() const
Get the file serial number, which distinguishes this file from all other files on the same device.
Definition Filesystem.h:144
void SetIsRegular(bool isRegular)
Set stat url as a regular.
Definition Filesystem.h:204
void SetIsSymLink(bool isSymLink)
Set stat url as a symbolic link.
Definition Filesystem.h:180
bool ATTR_DLL_LOCAL CreateDirectory(const std::string &path)
Make a directory.
Definition Filesystem.h:782
bool ATTR_DLL_LOCAL RemoveDirectory(const std::string &path, bool recursive=false)
Removes a directory.
Definition Filesystem.h:848
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:897
bool ATTR_DLL_LOCAL DirectoryExists(const std::string &path)
Verifying the Existence of a Directory.
Definition Filesystem.h:814
bool ATTR_DLL_LOCAL CopyFile(const std::string &filename, const std::string &destination)
Copy a file from source to destination.
Definition Filesystem.h:1078
bool ATTR_DLL_LOCAL DeleteFile(const std::string &filename)
Deletes a file.
Definition Filesystem.h:1042
bool ATTR_DLL_LOCAL StatFile(const std::string &filename, kodi::vfs::FileStatus &buffer)
Get file status.
Definition Filesystem.h:1004
bool ATTR_DLL_LOCAL FileExists(const std::string &filename, bool usecache=false)
Check if a file exists.
Definition Filesystem.h:949
bool ATTR_DLL_LOCAL RenameFile(const std::string &filename, const std::string &newFileName)
Rename a file name.
Definition Filesystem.h:1060
std::string ATTR_DLL_LOCAL GetFileMD5(const std::string &path)
Retrieve MD5sum of a file.
Definition Filesystem.h:1119
bool ATTR_DLL_LOCAL 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:1351
std::string ATTR_DLL_LOCAL TranslateSpecialProtocol(const std::string &source)
Returns the translated path.
Definition Filesystem.h:1297
bool ATTR_DLL_LOCAL IsURL(const std::string &path)
Checks specified path is a regular URL, e.g. "someprotocol://path/to/file".
Definition Filesystem.h:1627
std::string ATTR_DLL_LOCAL MakeLegalPath(const std::string &path)
Make directory name valid.
Definition Filesystem.h:1249
bool ATTR_DLL_LOCAL GetCookies(const std::string &url, std::string &cookies)
Get cookies stored by CURL in RFC 2109 format.
Definition Filesystem.h:1774
std::string ATTR_DLL_LOCAL GetDirectoryName(const std::string &path)
Return the directory name from given complete path string.
Definition Filesystem.h:1407
bool ATTR_DLL_LOCAL GetMimeType(const std::string &url, std::string &mimeType, const std::string &useragent="")
Get file mime type.
Definition Filesystem.h:1691
std::string ATTR_DLL_LOCAL MakeLegalFileName(const std::string &filename)
Make filename valid.
Definition Filesystem.h:1206
std::string ATTR_DLL_LOCAL GetCacheThumbName(const std::string &filename)
Returns a thumb cache filename.
Definition Filesystem.h:1163
void ATTR_DLL_LOCAL RemoveSlashAtEnd(std::string &path)
Remove the slash on given path name.
Definition Filesystem.h:1442
bool ATTR_DLL_LOCAL IsInternetStream(const std::string &path, bool strictCheck=false)
Checks the given path contains a known internet protocol.
Definition Filesystem.h:1519
bool ATTR_DLL_LOCAL IsLocal(const std::string &path)
Checks whether the given path refers to the own system.
Definition Filesystem.h:1596
bool ATTR_DLL_LOCAL IsRemote(const std::string &path)
Checks specified path for external network.
Definition Filesystem.h:1580
std::string ATTR_DLL_LOCAL GetFileName(const std::string &path)
Return the file name from given complete path string.
Definition Filesystem.h:1381
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:1462
bool ATTR_DLL_LOCAL GetContentType(const std::string &url, std::string &content, const std::string &useragent="")
Get file content-type.
Definition Filesystem.h:1732
bool ATTR_DLL_LOCAL GetHttpHeader(const std::string &url, HttpHeader &header)
To get HTTP header information.
Definition Filesystem.h:1660
bool ATTR_DLL_LOCAL IsOnLAN(const std::string &path)
Checks whether the specified path refers to a local network.
Definition Filesystem.h:1551
void ATTR_DLL_LOCAL Log(const ADDON_LOG loglevel, const char *format,...)
Add a message to Kodi's log.
Definition AddonBase.h:1939
Definition filesystem.h:186
Definition filesystem.h:198
Definition filesystem.h:229
Definition filesystem.h:243