File indexing completed on 2023-09-24 04:08:35
0001 /* 0002 kdiskfreespaceinfo.h 0003 SPDX-FileCopyrightText: 2008 Sebastian Trug <trueg@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-only 0006 */ 0007 0008 #ifndef _KDISK_FREE_SPACE_INFO_H_ 0009 #define _KDISK_FREE_SPACE_INFO_H_ 0010 0011 #include <QSharedDataPointer> 0012 #include <QString> 0013 0014 #include "kiocore_export.h" 0015 #include <kio/global.h> 0016 0017 class KDiskFreeSpaceInfoPrivate; 0018 0019 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 88) 0020 /** 0021 * \class KDiskFreeSpaceInfo kdiskfreespaceinfo.h KDiskFreeSpaceInfo 0022 * 0023 * \brief Determine the space left on an arbitrary partition. 0024 * 0025 * This class determines the free space left on the partition that holds a given 0026 * path. This path can be the mount point or any file or directory on the 0027 * partition. 0028 * 0029 * To find how much space is available on the partition containing @p path, 0030 * simply do the following: 0031 * 0032 * \code 0033 * KDiskFreeSpaceInfo info = KDiskFreeSpaceInfo::freeSpaceInfo( path ); 0034 * if( info.isValid() ) 0035 * doSomething( info.available() ); 0036 * \endcode 0037 * 0038 * \author Sebastian Trueg <trueg@kde.org> 0039 * 0040 * \since 4.2 0041 * 0042 * @deprecated Since 5.88, use KIO::FileSystemFreeSpaceJob or QStorageInfo instead. 0043 */ 0044 class KIOCORE_EXPORT KDiskFreeSpaceInfo 0045 { 0046 public: 0047 /** 0048 * Copy constructor 0049 */ 0050 KDiskFreeSpaceInfo(const KDiskFreeSpaceInfo &); 0051 0052 /** 0053 * Destructor 0054 */ 0055 ~KDiskFreeSpaceInfo(); 0056 0057 /** 0058 * Assignment operator 0059 */ 0060 KDiskFreeSpaceInfo &operator=(const KDiskFreeSpaceInfo &); 0061 0062 /** 0063 * \return \p true if the available disk space was successfully 0064 * determined and the values from mountPoint(), size(), available(), 0065 * and used() are valid. \p false otherwise. 0066 */ 0067 bool isValid() const; 0068 0069 /** 0070 * The mount point of the partition the requested path points to 0071 * 0072 * Only valid if isValid() returns \p true. 0073 */ 0074 QString mountPoint() const; 0075 0076 /** 0077 * The total size of the partition mounted at mountPoint() 0078 * 0079 * Only valid if isValid() returns \p true. 0080 * 0081 * \return Total size of the requested partition in bytes. 0082 */ 0083 KIO::filesize_t size() const; 0084 0085 /** 0086 * The available space in the partition mounted at mountPoint() 0087 * 0088 * Only valid if isValid() returns \p true. 0089 * 0090 * \return Available space left on the requested partition in bytes. 0091 */ 0092 KIO::filesize_t available() const; 0093 0094 /** 0095 * The used space in the partition mounted at mountPoint() 0096 * 0097 * Only valid if isValid() returns \p true. 0098 * 0099 * \return Used space on the requested partition in bytes. 0100 */ 0101 KIO::filesize_t used() const; 0102 0103 /** 0104 * Static method used to determine the free disk space. 0105 * 0106 * \param path An arbitrary path. The available space will be 0107 * determined for the partition containing path. 0108 * 0109 * Check isValid() to see if the process was successful. Then 0110 * use mountPoint(), size(), available(), and used() to access 0111 * the requested values. 0112 * 0113 * @deprecated Since 5.88, use KIO::FileSystemFreeSpaceJob or QStorageInfo instead. 0114 */ 0115 KIOCORE_DEPRECATED_VERSION(5, 88, "Use KIO::FileSystemFreeSpaceJob or QStorageInfo instead.") 0116 static KDiskFreeSpaceInfo freeSpaceInfo(const QString &path); 0117 0118 private: 0119 KDiskFreeSpaceInfo(); 0120 0121 QSharedDataPointer<KDiskFreeSpaceInfoPrivate> d; 0122 }; 0123 #endif // Deprecation 0124 0125 #endif