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 "AddonClass.h" 12 #include "LanguageHook.h" 13 #include "filesystem/File.h" 14 15 namespace XBMCAddon 16 { 17 namespace xbmcvfs 18 { 19 // 20 /// \defgroup python_stat Stat 21 /// \ingroup python_xbmcvfs 22 /// @{ 23 /// @brief **Get file or file system status.** 24 /// 25 /// \python_class{ xbmcvfs.Stat(path) } 26 /// 27 /// These class return information about a file. Execute (search) permission 28 /// is required on all of the directories in path that lead to the file. 29 /// 30 /// @param path [string] file or folder 31 /// 32 /// 33 /// ------------------------------------------------------------------------ 34 /// @python_v12 New function added 35 /// 36 /// **Example:** 37 /// ~~~~~~~~~~~~~{.py} 38 /// .. 39 /// st = xbmcvfs.Stat(path) 40 /// modified = st.st_mtime() 41 /// .. 42 /// ~~~~~~~~~~~~~ 43 // 44 class Stat : public AddonClass 45 { 46 struct __stat64 st; 47 48 public: Stat(const String & path)49 Stat(const String& path) 50 { 51 DelayedCallGuard dg; 52 XFILE::CFile::Stat(path, &st); 53 } 54 55 #ifdef DOXYGEN_SHOULD_USE_THIS 56 /// 57 /// \ingroup python_stat 58 /// @brief \python_func{ st_mode() } 59 /// To get file protection. 60 /// 61 /// @return st_mode 62 /// 63 st_mode(); 64 #else st_mode()65 inline long long st_mode() { return st.st_mode; }; 66 #endif 67 68 #ifdef DOXYGEN_SHOULD_USE_THIS 69 /// 70 /// \ingroup python_stat 71 /// @brief \python_func{ st_ino() } 72 /// To get inode number. 73 /// 74 /// @return st_ino 75 /// 76 st_ino(); 77 #else st_ino()78 inline long long st_ino() { return st.st_ino; }; 79 #endif 80 81 #ifdef DOXYGEN_SHOULD_USE_THIS 82 /// 83 /// \ingroup python_stat 84 /// @brief \python_func{ st_dev() } 85 /// To get ID of device containing file. 86 /// 87 /// The st_dev field describes the device on which this file resides. 88 /// 89 /// @return st_dev 90 /// 91 st_dev(); 92 #else st_dev()93 inline long long st_dev() { return st.st_dev; }; 94 #endif 95 96 #ifdef DOXYGEN_SHOULD_USE_THIS 97 /// 98 /// \ingroup python_stat 99 /// @brief \python_func{ st_nlink() } 100 /// To get number of hard links. 101 /// 102 /// @return st_nlink 103 /// 104 st_nlink(); 105 #else st_nlink()106 inline long long st_nlink() { return st.st_nlink; }; 107 #endif 108 109 #ifdef DOXYGEN_SHOULD_USE_THIS 110 /// 111 /// \ingroup python_stat 112 /// @brief \python_func{ st_uid() } 113 /// To get user ID of owner. 114 /// 115 /// @return st_uid 116 /// 117 st_uid(); 118 #else st_uid()119 inline long long st_uid() { return st.st_uid; }; 120 #endif 121 122 #ifdef DOXYGEN_SHOULD_USE_THIS 123 /// 124 /// \ingroup python_stat 125 /// @brief \python_func{ st_gid() } 126 /// To get group ID of owner. 127 /// 128 /// @return st_gid 129 /// 130 st_gid(); 131 #else st_gid()132 inline long long st_gid() { return st.st_gid; }; 133 #endif 134 135 #ifdef DOXYGEN_SHOULD_USE_THIS 136 /// 137 /// \ingroup python_stat 138 /// @brief \python_func{ st_size() } 139 /// To get total size, in bytes. 140 /// 141 /// The st_size field gives the size of the file (if it is a regular file 142 /// or a symbolic link) in bytes. The size of a symbolic link (only on 143 /// Linux and Mac OS X) is the length of the pathname it contains, without 144 /// a terminating null byte. 145 /// 146 /// @return st_size 147 /// 148 st_size(); 149 #else st_size()150 inline long long st_size() { return st.st_size; }; 151 #endif 152 153 #ifdef DOXYGEN_SHOULD_USE_THIS 154 /// 155 /// \ingroup python_stat 156 /// @brief \python_func{ st_atime() } 157 /// To get time of last access. 158 /// 159 /// @return st_atime 160 /// 161 st_atime(); 162 #else atime()163 inline long long atime() { return st.st_atime; }; //names st_atime/st_mtime/st_ctime are used by sys/stat.h 164 #endif 165 166 #ifdef DOXYGEN_SHOULD_USE_THIS 167 /// 168 /// \ingroup python_stat 169 /// @brief \python_func{ st_mtime() } 170 /// To get time of last modification. 171 /// 172 /// @return st_mtime 173 /// 174 st_mtime(); 175 #else mtime()176 inline long long mtime() { return st.st_mtime; }; 177 #endif 178 179 #ifdef DOXYGEN_SHOULD_USE_THIS 180 /// 181 /// \ingroup python_stat 182 /// @brief \python_func{ st_ctime() } 183 /// To get time of last status change. 184 /// 185 /// @return st_ctime 186 /// 187 st_ctime(); 188 #else ctime()189 inline long long ctime() { return st.st_ctime; }; 190 #endif 191 }; 192 /// @} 193 } 194 } 195 196