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 =
"",
565 : m_label(label), m_path(path), m_folder(folder), m_size(size), m_dateTime(dateTime)
580 : m_label(dirEntry.label ? dirEntry.label :
""),
581 m_path(dirEntry.path ? dirEntry.path :
""),
582 m_folder(dirEntry.folder),
583 m_size(dirEntry.size),
584 m_dateTime(dirEntry.date_time)
614 const std::string&
Label(
void)
const {
return m_label; }
622 const std::string&
Title(
void)
const {
return m_title; }
630 const std::string&
Path(
void)
const {
return m_path; }
646 int64_t
Size(
void)
const {
return m_size; }
662 void SetLabel(
const std::string& label) { m_label = label; }
670 void SetTitle(
const std::string& title) { m_title = title; }
678 void SetPath(
const std::string& path) { m_path = path; }
715 void AddProperty(
const std::string&
id,
const std::string& value) { m_properties[id] = value; }
729 const std::map<std::string, std::string>&
GetProperties()
const {
return m_properties; }
738 std::map<std::string, std::string> m_properties;
780 using namespace kodi::addon;
782 return CPrivateBase::m_interface->toKodi->kodi_filesystem->create_directory(
783 CPrivateBase::m_interface->toKodi->kodiBase, path.c_str());
812 using namespace kodi::addon;
814 return CPrivateBase::m_interface->toKodi->kodi_filesystem->directory_exists(
815 CPrivateBase::m_interface->toKodi->kodiBase, path.c_str());
844inline bool ATTR_DLL_LOCAL
RemoveDirectory(
const std::string& path,
bool recursive =
false)
846 using namespace kodi::addon;
849 return CPrivateBase::m_interface->toKodi->kodi_filesystem->remove_directory(
850 CPrivateBase::m_interface->toKodi->kodiBase, path.c_str());
852 return CPrivateBase::m_interface->toKodi->kodi_filesystem->remove_directory_recursive(
853 CPrivateBase::m_interface->toKodi->kodiBase, path.c_str());
894 const std::string& mask,
895 std::vector<kodi::vfs::CDirEntry>& items)
897 using namespace kodi::addon;
900 unsigned int num_items = 0;
901 if (CPrivateBase::m_interface->toKodi->kodi_filesystem->get_directory(
902 CPrivateBase::m_interface->toKodi->kodiBase, path.c_str(), mask.c_str(), &dir_list,
907 for (
unsigned int i = 0; i < num_items; ++i)
908 items.emplace_back(dir_list[i]);
910 CPrivateBase::m_interface->toKodi->kodi_filesystem->free_directory(
911 CPrivateBase::m_interface->toKodi->kodiBase, dir_list, num_items);
945inline bool ATTR_DLL_LOCAL
FileExists(
const std::string& filename,
bool usecache =
false)
947 using namespace kodi::addon;
949 return CPrivateBase::m_interface->toKodi->kodi_filesystem->file_exists(
950 CPrivateBase::m_interface->toKodi->kodiBase, filename.c_str(), usecache);
1002 using namespace kodi::addon;
1004 return CPrivateBase::m_interface->toKodi->kodi_filesystem->stat_file(
1005 CPrivateBase::m_interface->toKodi->kodiBase, filename.c_str(), buffer);
1038inline bool ATTR_DLL_LOCAL
DeleteFile(
const std::string& filename)
1040 using namespace kodi::addon;
1042 return CPrivateBase::m_interface->toKodi->kodi_filesystem->delete_file(
1043 CPrivateBase::m_interface->toKodi->kodiBase, filename.c_str());
1056inline bool ATTR_DLL_LOCAL
RenameFile(
const std::string& filename,
const std::string& newFileName)
1058 using namespace kodi::addon;
1060 return CPrivateBase::m_interface->toKodi->kodi_filesystem->rename_file(
1061 CPrivateBase::m_interface->toKodi->kodiBase, filename.c_str(), newFileName.c_str());
1074inline bool ATTR_DLL_LOCAL
CopyFile(
const std::string& filename,
const std::string& destination)
1076 using namespace kodi::addon;
1078 return CPrivateBase::m_interface->toKodi->kodi_filesystem->copy_file(
1079 CPrivateBase::m_interface->toKodi->kodiBase, filename.c_str(), destination.c_str());
1115inline std::string ATTR_DLL_LOCAL
GetFileMD5(
const std::string& path)
1117 using namespace kodi::addon;
1119 std::string strReturn;
1120 char* strMd5 = CPrivateBase::m_interface->toKodi->kodi_filesystem->get_file_md5(
1121 CPrivateBase::m_interface->toKodi->kodiBase, path.c_str());
1122 if (strMd5 !=
nullptr)
1124 if (std::strlen(strMd5))
1126 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
1161 using namespace kodi::addon;
1163 std::string strReturn;
1164 char* strThumbName = CPrivateBase::m_interface->toKodi->kodi_filesystem->get_cache_thumb_name(
1165 CPrivateBase::m_interface->toKodi->kodiBase, filename.c_str());
1166 if (strThumbName !=
nullptr)
1168 if (std::strlen(strThumbName))
1169 strReturn = strThumbName;
1170 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
1204 using namespace kodi::addon;
1206 std::string strReturn;
1207 char* strLegalFileName = CPrivateBase::m_interface->toKodi->kodi_filesystem->make_legal_filename(
1208 CPrivateBase::m_interface->toKodi->kodiBase, filename.c_str());
1209 if (strLegalFileName !=
nullptr)
1211 if (std::strlen(strLegalFileName))
1212 strReturn = strLegalFileName;
1213 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
1247 using namespace kodi::addon;
1249 std::string strReturn;
1250 char* strLegalPath = CPrivateBase::m_interface->toKodi->kodi_filesystem->make_legal_path(
1251 CPrivateBase::m_interface->toKodi->kodiBase, path.c_str());
1252 if (strLegalPath !=
nullptr)
1254 if (std::strlen(strLegalPath))
1255 strReturn = strLegalPath;
1256 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
1295 using namespace kodi::addon;
1297 std::string strReturn;
1298 char* protocol = CPrivateBase::m_interface->toKodi->kodi_filesystem->translate_special_protocol(
1299 CPrivateBase::m_interface->toKodi->kodiBase, source.c_str());
1300 if (protocol !=
nullptr)
1302 if (std::strlen(protocol))
1303 strReturn = protocol;
1304 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
1350 uint64_t& available)
1352 using namespace kodi::addon;
1354 return CPrivateBase::m_interface->toKodi->kodi_filesystem->get_disk_space(
1355 CPrivateBase::m_interface->toKodi->kodiBase, path.c_str(), &capacity, &free, &available);
1380 const size_t slash = path.find_last_of(
"/\\");
1381 return path.substr(slash + 1);
1408 size_t iPosSlash = path.find_last_of(
"/\\");
1409 if (iPosSlash == std::string::npos)
1412 size_t iPosBar = path.rfind(
'|');
1413 if (iPosBar == std::string::npos)
1414 return path.substr(0, iPosSlash + 1);
1416 return path.substr(0, iPosSlash + 1) + path.substr(iPosBar);
1442 char last = path[path.size() - 1];
1443 if (last ==
'/' || last ==
'\\')
1444 path.erase(path.size() - 1);
1458inline unsigned int ATTR_DLL_LOCAL
GetChunkSize(
unsigned int chunk,
unsigned int minimum)
1461 return chunk * ((minimum + chunk - 1) / chunk);
1517 using namespace kodi::addon;
1519 return CPrivateBase::m_interface->toKodi->kodi_filesystem->is_internet_stream(
1520 CPrivateBase::m_interface->toKodi->kodiBase, path.c_str(), strictCheck);
1547inline bool ATTR_DLL_LOCAL
IsOnLAN(
const std::string& path)
1549 using namespace kodi::addon;
1551 return CPrivateBase::m_interface->toKodi->kodi_filesystem->is_on_lan(
1552 CPrivateBase::m_interface->toKodi->kodiBase, path.c_str());
1576inline bool ATTR_DLL_LOCAL
IsRemote(
const std::string& path)
1578 using namespace kodi::addon;
1580 return CPrivateBase::m_interface->toKodi->kodi_filesystem->is_remote(
1581 CPrivateBase::m_interface->toKodi->kodiBase, path.c_str());
1592inline bool ATTR_DLL_LOCAL
IsLocal(
const std::string& path)
1594 using namespace kodi::addon;
1596 return CPrivateBase::m_interface->toKodi->kodi_filesystem->is_local(
1597 CPrivateBase::m_interface->toKodi->kodiBase, path.c_str());
1623inline bool ATTR_DLL_LOCAL
IsURL(
const std::string& path)
1625 using namespace kodi::addon;
1627 return CPrivateBase::m_interface->toKodi->kodi_filesystem->is_url(
1628 CPrivateBase::m_interface->toKodi->kodiBase, path.c_str());
1658 using namespace ::kodi::addon;
1660 return CPrivateBase::m_interface->toKodi->kodi_filesystem->get_http_header(
1661 CPrivateBase::m_interface->toKodi->kodiBase, url.c_str(), &header.m_handle);
1688 std::string& mimeType,
1689 const std::string& useragent =
"")
1691 using namespace ::kodi::addon;
1693 char* cMimeType =
nullptr;
1694 bool ret = CPrivateBase::m_interface->toKodi->kodi_filesystem->get_mime_type(
1695 CPrivateBase::m_interface->toKodi->kodiBase, url.c_str(), &cMimeType, useragent.c_str());
1696 if (cMimeType !=
nullptr)
1698 mimeType = cMimeType;
1699 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
1729 std::string& content,
1730 const std::string& useragent =
"")
1732 using namespace ::kodi::addon;
1734 char* cContent =
nullptr;
1735 bool ret = CPrivateBase::m_interface->toKodi->kodi_filesystem->get_content_type(
1736 CPrivateBase::m_interface->toKodi->kodiBase, url.c_str(), &cContent, useragent.c_str());
1737 if (cContent !=
nullptr)
1740 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
1770inline bool ATTR_DLL_LOCAL
GetCookies(
const std::string& url, std::string& cookies)
1772 using namespace ::kodi::addon;
1774 char* cCookies =
nullptr;
1775 bool ret = CPrivateBase::m_interface->toKodi->kodi_filesystem->get_cookies(
1776 CPrivateBase::m_interface->toKodi->kodiBase, url.c_str(), &cCookies);
1777 if (cCookies !=
nullptr)
1780 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
1861 bool OpenFile(
const std::string& filename,
unsigned int flags = 0)
1863 using namespace kodi::addon;
1866 m_file = CPrivateBase::m_interface->toKodi->kodi_filesystem->open_file(
1867 CPrivateBase::m_interface->toKodi->kodiBase, filename.c_str(), flags);
1868 return m_file !=
nullptr;
1886 using namespace kodi::addon;
1892 m_file = CPrivateBase::m_interface->toKodi->kodi_filesystem->open_file_for_write(
1893 CPrivateBase::m_interface->toKodi->kodiBase, filename.c_str(), overwrite);
1897 if (CPrivateBase::m_interface->toKodi->kodi_filesystem->directory_exists(
1898 CPrivateBase::m_interface->toKodi->kodiBase, cacheDirectory.c_str()) ||
1899 CPrivateBase::m_interface->toKodi->kodi_filesystem->create_directory(
1900 CPrivateBase::m_interface->toKodi->kodiBase, cacheDirectory.c_str()))
1901 m_file = CPrivateBase::m_interface->toKodi->kodi_filesystem->open_file_for_write(
1902 CPrivateBase::m_interface->toKodi->kodiBase, filename.c_str(), overwrite);
1904 return m_file !=
nullptr;
1914 bool IsOpen()
const {
return m_file !=
nullptr; }
1923 using namespace kodi::addon;
1927 CPrivateBase::m_interface->toKodi->kodi_filesystem->close_file(
1928 CPrivateBase::m_interface->toKodi->kodiBase, m_file);
1942 using namespace kodi::addon;
1944 m_file = CPrivateBase::m_interface->toKodi->kodi_filesystem->curl_create(
1945 CPrivateBase::m_interface->toKodi->kodiBase, url.c_str());
1946 return m_file !=
nullptr;
1961 using namespace kodi::addon;
1968 return CPrivateBase::m_interface->toKodi->kodi_filesystem->curl_add_option(
1969 CPrivateBase::m_interface->toKodi->kodiBase, m_file, type, name.c_str(), value.c_str());
1982 using namespace kodi::addon;
1989 return CPrivateBase::m_interface->toKodi->kodi_filesystem->curl_open(
1990 CPrivateBase::m_interface->toKodi->kodiBase, m_file, flags);
2005 ssize_t
Read(
void* ptr,
size_t size)
2007 using namespace kodi::addon;
2011 return CPrivateBase::m_interface->toKodi->kodi_filesystem->read_file(
2012 CPrivateBase::m_interface->toKodi->kodiBase, m_file, ptr, size);
2051 using namespace kodi::addon;
2066 char buffer[1025]{};
2067 if (CPrivateBase::m_interface->toKodi->kodi_filesystem->read_file_string(
2068 CPrivateBase::m_interface->toKodi->kodiBase, m_file, buffer,
sizeof(buffer) - 1))
2071 return !line.empty();
2087 ssize_t
Write(
const void* ptr,
size_t size)
2089 using namespace kodi::addon;
2093 return CPrivateBase::m_interface->toKodi->kodi_filesystem->write_file(
2094 CPrivateBase::m_interface->toKodi->kodiBase, m_file, ptr, size);
2114 using namespace kodi::addon;
2118 CPrivateBase::m_interface->toKodi->kodi_filesystem->flush_file(
2119 CPrivateBase::m_interface->toKodi->kodiBase, m_file);
2141 int64_t
Seek(int64_t position,
int whence = SEEK_SET)
2143 using namespace kodi::addon;
2147 return CPrivateBase::m_interface->toKodi->kodi_filesystem->seek_file(
2148 CPrivateBase::m_interface->toKodi->kodiBase, m_file, position, whence);
2161 using namespace kodi::addon;
2165 return CPrivateBase::m_interface->toKodi->kodi_filesystem->truncate_file(
2166 CPrivateBase::m_interface->toKodi->kodiBase, m_file, size);
2178 using namespace kodi::addon;
2182 return CPrivateBase::m_interface->toKodi->kodi_filesystem->get_file_position(
2183 CPrivateBase::m_interface->toKodi->kodiBase, m_file);
2195 using namespace kodi::addon;
2199 return CPrivateBase::m_interface->toKodi->kodi_filesystem->get_file_length(
2200 CPrivateBase::m_interface->toKodi->kodiBase, m_file);
2212 using namespace kodi::addon;
2216 int64_t length = CPrivateBase::m_interface->toKodi->kodi_filesystem->get_file_length(
2217 CPrivateBase::m_interface->toKodi->kodiBase, m_file);
2218 int64_t position = CPrivateBase::m_interface->toKodi->kodi_filesystem->get_file_position(
2219 CPrivateBase::m_interface->toKodi->kodiBase, m_file);
2220 return position >= length;
2232 using namespace kodi::addon;
2236 return CPrivateBase::m_interface->toKodi->kodi_filesystem->get_file_chunk_size(
2237 CPrivateBase::m_interface->toKodi->kodiBase, m_file);
2249 using namespace kodi::addon;
2253 return CPrivateBase::m_interface->toKodi->kodi_filesystem->io_control_get_seek_possible(
2254 CPrivateBase::m_interface->toKodi->kodiBase, m_file);
2270 using namespace kodi::addon;
2274 return CPrivateBase::m_interface->toKodi->kodi_filesystem->io_control_get_cache_status(
2275 CPrivateBase::m_interface->toKodi->kodiBase, m_file, status);
2288 using namespace kodi::addon;
2292 return CPrivateBase::m_interface->toKodi->kodi_filesystem->io_control_set_cache_rate(
2293 CPrivateBase::m_interface->toKodi->kodiBase, m_file, rate);
2306 using namespace kodi::addon;
2310 return CPrivateBase::m_interface->toKodi->kodi_filesystem->io_control_set_retry(
2311 CPrivateBase::m_interface->toKodi->kodiBase, m_file, retry);
2325 using namespace kodi::addon;
2330 "kodi::vfs::CURLCreate(...) needed to call before GetPropertyValue!");
2333 std::vector<std::string> values = GetPropertyValues(type, name);
2351 const std::string& name)
const
2353 using namespace kodi::addon;
2358 "kodi::vfs::CURLCreate(...) needed to call before GetPropertyValues!");
2359 return std::vector<std::string>();
2362 char** res(CPrivateBase::m_interface->toKodi->kodi_filesystem->get_property_values(
2363 CPrivateBase::m_interface->toKodi->kodiBase, m_file, type, name.c_str(), &numValues));
2366 std::vector<std::string> vecReturn;
2367 vecReturn.reserve(numValues);
2368 for (
int i = 0; i < numValues; ++i)
2370 vecReturn.emplace_back(res[i]);
2372 CPrivateBase::m_interface->toKodi->free_string_array(
2373 CPrivateBase::m_interface->toKodi->kodiBase, res, numValues);
2376 return std::vector<std::string>();
2388 using namespace kodi::addon;
2392 return CPrivateBase::m_interface->toKodi->kodi_filesystem->get_file_download_speed(
2393 CPrivateBase::m_interface->toKodi->kodiBase, m_file);
2398 void* m_file =
nullptr;
Definition AddonBase.h:206
Definition Filesystem.h:548
Definition Filesystem.h:1835
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:715
const std::map< std::string, std::string > & GetProperties() const
Get the present properties list on directory entry.
Definition Filesystem.h:729
void SetPath(const std::string &path)
Set the path of the entry.
Definition Filesystem.h:678
void SetTitle(const std::string &title)
Set the title name.
Definition Filesystem.h:670
const std::string & Path(void) const
Get the path of the entry.
Definition Filesystem.h:630
void SetDateTime(time_t dateTime)
Set file time and date for a new entry.
Definition Filesystem.h:702
void SetFolder(bool folder)
Set the entry defined as folder.
Definition Filesystem.h:686
void SetLabel(const std::string &label)
Set the label name.
Definition Filesystem.h:662
void ClearProperties()
Clear all present properties.
Definition Filesystem.h:721
time_t DateTime()
Get file time and date for a new entry.
Definition Filesystem.h:654
const std::string & Title(void) const
Get the optional title of entry.
Definition Filesystem.h:622
bool IsFolder(void) const
Used to check entry is folder.
Definition Filesystem.h:638
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:646
const std::string & Label(void) const
Get the directory entry name.
Definition Filesystem.h:614
void SetSize(int64_t size)
Set a file size for a new entry.
Definition Filesystem.h:694
void Flush()
Flush buffered data.
Definition Filesystem.h:2112
bool IsOpen() const
Check file is opened.
Definition Filesystem.h:1914
bool IoControlSetCacheRate(uint32_t rate)
Unsigned int with speed limit for caching in bytes per second.
Definition Filesystem.h:2286
bool AtEnd() const
Checks the file access is on end position.
Definition Filesystem.h:2210
int64_t Seek(int64_t position, int whence=SEEK_SET)
Set the file's current position.
Definition Filesystem.h:2141
int64_t GetLength() const
Get the file size of an open file.
Definition Filesystem.h:2193
bool IoControlGetCacheStatus(CacheStatus &status) const
To check a running stream on file for state of his cache.
Definition Filesystem.h:2268
int GetChunkSize() const
Get the chunk size for an open file.
Definition Filesystem.h:2230
bool CURLOpen(unsigned int flags=0)
Open the curl file created with CURLCreate.
Definition Filesystem.h:1980
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:1884
int Truncate(int64_t size)
Truncate a file to the requested size.
Definition Filesystem.h:2159
void Close()
Close an open file.
Definition Filesystem.h:1921
bool CURLCreate(const std::string &url)
Create a Curl representation.
Definition Filesystem.h:1940
bool IoControlGetSeekPossible() const
To check seek possible on current stream by file.
Definition Filesystem.h:2247
double GetFileDownloadSpeed() const
Get the current download speed of file if loaded from web.
Definition Filesystem.h:2386
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:1861
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:1849
const std::vector< std::string > GetPropertyValues(FilePropertyTypes type, const std::string &name) const
Retrieve file property values.
Definition Filesystem.h:2350
ssize_t Write(const void *ptr, size_t size)
Write to a file opened in write mode.
Definition Filesystem.h:2087
bool CURLAddOption(CURLOptiontype type, const std::string &name, const std::string &value)
Add options to the curl file created with CURLCreate.
Definition Filesystem.h:1959
bool IoControlSetRetry(bool retry)
Enable/disable retry within the protocol handler (if supported).
Definition Filesystem.h:2304
bool ReadLine(std::string &line)
Read a string from an open file.
Definition Filesystem.h:2049
const std::string GetPropertyValue(FilePropertyTypes type, const std::string &name) const
Retrieve a file property.
Definition Filesystem.h:2323
int64_t GetPosition() const
The current offset in an open file.
Definition Filesystem.h:2176
ssize_t Read(void *ptr, size_t size)
Read from an open file.
Definition Filesystem.h:2005
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: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
bool ATTR_DLL_LOCAL CopyFile(const std::string &filename, const std::string &destination)
Copy a file from source to destination.
Definition Filesystem.h:1074
bool ATTR_DLL_LOCAL DeleteFile(const std::string &filename)
Deletes a file.
Definition Filesystem.h:1038
bool ATTR_DLL_LOCAL StatFile(const std::string &filename, kodi::vfs::FileStatus &buffer)
Get file status.
Definition Filesystem.h:1000
bool ATTR_DLL_LOCAL FileExists(const std::string &filename, bool usecache=false)
Check if a file exists.
Definition Filesystem.h:945
bool ATTR_DLL_LOCAL RenameFile(const std::string &filename, const std::string &newFileName)
Rename a file name.
Definition Filesystem.h:1056
std::string ATTR_DLL_LOCAL GetFileMD5(const std::string &path)
Retrieve MD5sum of a file.
Definition Filesystem.h:1115
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:1347
std::string ATTR_DLL_LOCAL TranslateSpecialProtocol(const std::string &source)
Returns the translated path.
Definition Filesystem.h:1293
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:1623
std::string ATTR_DLL_LOCAL MakeLegalPath(const std::string &path)
Make directory name valid.
Definition Filesystem.h:1245
bool ATTR_DLL_LOCAL GetCookies(const std::string &url, std::string &cookies)
Get cookies stored by CURL in RFC 2109 format.
Definition Filesystem.h:1770
std::string ATTR_DLL_LOCAL GetDirectoryName(const std::string &path)
Return the directory name from given complete path string.
Definition Filesystem.h:1403
bool ATTR_DLL_LOCAL GetMimeType(const std::string &url, std::string &mimeType, const std::string &useragent="")
Get file mime type.
Definition Filesystem.h:1687
std::string ATTR_DLL_LOCAL MakeLegalFileName(const std::string &filename)
Make filename valid.
Definition Filesystem.h:1202
std::string ATTR_DLL_LOCAL GetCacheThumbName(const std::string &filename)
Returns a thumb cache filename.
Definition Filesystem.h:1159
void ATTR_DLL_LOCAL RemoveSlashAtEnd(std::string &path)
Remove the slash on given path name.
Definition Filesystem.h:1438
bool ATTR_DLL_LOCAL IsInternetStream(const std::string &path, bool strictCheck=false)
Checks the given path contains a known internet protocol.
Definition Filesystem.h:1515
bool ATTR_DLL_LOCAL IsLocal(const std::string &path)
Checks whether the given path refers to the own system.
Definition Filesystem.h:1592
bool ATTR_DLL_LOCAL IsRemote(const std::string &path)
Checks specified path for external network.
Definition Filesystem.h:1576
std::string ATTR_DLL_LOCAL GetFileName(const std::string &path)
Return the file name from given complete path string.
Definition Filesystem.h:1377
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
bool ATTR_DLL_LOCAL GetContentType(const std::string &url, std::string &content, const std::string &useragent="")
Get file content-type.
Definition Filesystem.h:1728
bool ATTR_DLL_LOCAL GetHttpHeader(const std::string &url, HttpHeader &header)
To get HTTP header information.
Definition Filesystem.h:1656
bool ATTR_DLL_LOCAL IsOnLAN(const std::string &path)
Checks whether the specified path refers to a local network.
Definition Filesystem.h:1547
void ATTR_DLL_LOCAL Log(const ADDON_LOG loglevel, const char *format,...)
Add a message to Kodi's log.
Definition AddonBase.h:1938
Definition filesystem.h:186
Definition filesystem.h:198
Definition filesystem.h:229
Definition filesystem.h:243