1 /* 2 * Copyright (C) 2005-2018 Team Kodi 3 * This file is part of Kodi - https://kodi.tv 4 * 5 * SPDX-License-Identifier: GPL-2.0-or-later 6 * See LICENSES/README.md for more information. 7 */ 8 9 #pragma once 10 11 #include "addons/kodi-dev-kit/include/kodi/Filesystem.h" 12 13 extern "C" 14 { 15 16 struct VFSDirEntry; 17 struct AddonGlobalInterface; 18 19 namespace ADDON 20 { 21 22 struct Interface_Filesystem 23 { 24 static void Init(AddonGlobalInterface* addonInterface); 25 static void DeInit(AddonGlobalInterface* addonInterface); 26 27 static unsigned int TranslateFileReadBitsToKodi(unsigned int addonFlags); 28 29 /*! 30 * @brief callback functions from add-on to kodi 31 * 32 * @note For add of new functions use the "_" style to identify direct a 33 * add-on callback function. Everything with CamelCase is only for the 34 * usage in Kodi only. 35 * 36 * The parameter `kodiBase` is used to become the pointer for a `CAddonDll` 37 * class. 38 */ 39 ///@{ 40 static bool can_open_directory(void* kodiBase, const char* url); 41 static bool create_directory(void* kodiBase, const char* path); 42 static bool directory_exists(void* kodiBase, const char* path); 43 static bool remove_directory(void* kodiBase, const char* path); 44 static bool remove_directory_recursive(void* kodiBase, const char* path); 45 static bool get_directory(void* kodiBase, 46 const char* path, 47 const char* mask, 48 struct VFSDirEntry** items, 49 unsigned int* num_items); 50 static void free_directory(void* kodiBase, struct VFSDirEntry* items, unsigned int num_items); 51 52 static bool file_exists(void* kodiBase, const char* filename, bool useCache); 53 static bool stat_file(void* kodiBase, const char* filename, struct STAT_STRUCTURE* buffer); 54 static bool delete_file(void* kodiBase, const char* filename); 55 static bool rename_file(void* kodiBase, const char* filename, const char* newFileName); 56 static bool copy_file(void* kodiBase, const char* filename, const char* dest); 57 static char* get_file_md5(void* kodiBase, const char* filename); 58 static char* get_cache_thumb_name(void* kodiBase, const char* filename); 59 static char* make_legal_filename(void* kodiBase, const char* filename); 60 static char* make_legal_path(void* kodiBase, const char* path); 61 static char* translate_special_protocol(void* kodiBase, const char* strSource); 62 static bool get_disk_space( 63 void* kodiBase, const char* path, uint64_t* capacity, uint64_t* free, uint64_t* available); 64 static bool is_internet_stream(void* kodiBase, const char* path, bool strictCheck); 65 static bool is_on_lan(void* kodiBase, const char* path); 66 static bool is_remote(void* kodiBase, const char* path); 67 static bool is_local(void* kodiBase, const char* path); 68 static bool is_url(void* kodiBase, const char* path); 69 70 static bool get_http_header(void* kodiBase, const char* url, struct KODI_HTTP_HEADER* headers); 71 static bool get_mime_type(void* kodiBase, const char* url, char** content, const char* useragent); 72 static bool get_content_type(void* kodiBase, 73 const char* url, 74 char** content, 75 const char* useragent); 76 static bool get_cookies(void* kodiBase, const char* url, char** cookies); 77 78 /*! 79 * @brief Callback functions addon class kodi::vfs::CFile 80 */ 81 ///@{ 82 static bool http_header_create(void* kodiBase, struct KODI_HTTP_HEADER* headers); 83 static void http_header_free(void* kodiBase, struct KODI_HTTP_HEADER* headers); 84 85 static char* http_header_get_value(void* kodiBase, void* handle, const char* param); 86 static char** http_header_get_values(void* kodiBase, 87 void* handle, 88 const char* param, 89 int* length); 90 static char* http_header_get_header(void* kodiBase, void* handle); 91 static char* http_header_get_mime_type(void* kodiBase, void* handle); 92 static char* http_header_get_charset(void* kodiBase, void* handle); 93 static char* http_header_get_proto_line(void* kodiBase, void* handle); 94 ///@} 95 96 /*! 97 * @brief Callback functions addon class kodi::vfs::CFile 98 */ 99 ///@{ 100 static void* open_file(void* kodiBase, const char* filename, unsigned int flags); 101 static void* open_file_for_write(void* kodiBase, const char* filename, bool overwrite); 102 static ssize_t read_file(void* kodiBase, void* file, void* ptr, size_t size); 103 static bool read_file_string(void* kodiBase, void* file, char* szLine, int lineLength); 104 static ssize_t write_file(void* kodiBase, void* file, const void* ptr, size_t size); 105 static void flush_file(void* kodiBase, void* file); 106 static int64_t seek_file(void* kodiBase, void* file, int64_t position, int whence); 107 static int truncate_file(void* kodiBase, void* file, int64_t size); 108 static int64_t get_file_position(void* kodiBase, void* file); 109 static int64_t get_file_length(void* kodiBase, void* file); 110 static double get_file_download_speed(void* kodiBase, void* file); 111 static void close_file(void* kodiBase, void* file); 112 static int get_file_chunk_size(void* kodiBase, void* file); 113 static bool io_control_get_seek_possible(void* kodiBase, void* file); 114 static bool io_control_get_cache_status(void* kodiBase, 115 void* file, 116 struct VFS_CACHE_STATUS_DATA* status); 117 static bool io_control_set_cache_rate(void* kodiBase, void* file, unsigned int rate); 118 static bool io_control_set_retry(void* kodiBase, void* file, bool retry); 119 static char** get_property_values( 120 void* kodiBase, void* file, int type, const char* name, int* numValues); 121 122 static void* curl_create(void* kodiBase, const char* url); 123 static bool curl_add_option( 124 void* kodiBase, void* file, int type, const char* name, const char* value); 125 static bool curl_open(void* kodiBase, void* file, unsigned int flags); 126 ///@} 127 ///@} 128 }; 129 130 } /* namespace ADDON */ 131 } /* extern "C" */ 132