1 /*
2     kdiskfreespaceinfo.h
3     SPDX-FileCopyrightText: 2008 Sebastian Trug <trueg@kde.org>
4 
5     SPDX-License-Identifier: LGPL-2.0-only
6 */
7 
8 #ifndef _KDISK_FREE_SPACE_INFO_H_
9 #define _KDISK_FREE_SPACE_INFO_H_
10 
11 #include <QSharedDataPointer>
12 #include <QString>
13 
14 #include "kiocore_export.h"
15 #include <kio/global.h>
16 
17 class KDiskFreeSpaceInfoPrivate;
18 
19 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 88)
20 /**
21  * \class KDiskFreeSpaceInfo kdiskfreespaceinfo.h KDiskFreeSpaceInfo
22  *
23  * \brief Determine the space left on an arbitrary partition.
24  *
25  * This class determines the free space left on the partition that holds a given
26  * path.  This path can be the mount point or any file or directory on the
27  * partition.
28  *
29  * To find how much space is available on the partition containing @p path,
30  * simply do the following:
31  *
32  * \code
33  * KDiskFreeSpaceInfo info = KDiskFreeSpaceInfo::freeSpaceInfo( path );
34  * if( info.isValid() )
35  *    doSomething( info.available() );
36  * \endcode
37  *
38  * \author Sebastian Trueg <trueg@kde.org>
39  *
40  * \since 4.2
41  *
42  * @deprecated Since 5.88, use KIO::FileSystemFreeSpaceJob or QStorageInfo instead.
43  */
44 class KIOCORE_EXPORT KDiskFreeSpaceInfo
45 {
46 public:
47     /**
48      * Copy constructor
49      */
50     KDiskFreeSpaceInfo(const KDiskFreeSpaceInfo &);
51 
52     /**
53      * Destructor
54      */
55     ~KDiskFreeSpaceInfo();
56 
57     /**
58      * Assignment operator
59      */
60     KDiskFreeSpaceInfo &operator=(const KDiskFreeSpaceInfo &);
61 
62     /**
63      * \return \p true if the available disk space was successfully
64      * determined and the values from mountPoint(), size(), available(),
65      * and used() are valid. \p false otherwise.
66      */
67     bool isValid() const;
68 
69     /**
70      * The mount point of the partition the requested path points to
71      *
72      * Only valid if isValid() returns \p true.
73      */
74     QString mountPoint() const;
75 
76     /**
77      * The total size of the partition mounted at mountPoint()
78      *
79      * Only valid if isValid() returns \p true.
80      *
81      * \return Total size of the requested partition in bytes.
82      */
83     KIO::filesize_t size() const;
84 
85     /**
86      * The available space in the partition mounted at mountPoint()
87      *
88      * Only valid if isValid() returns \p true.
89      *
90      * \return Available space left on the requested partition in bytes.
91      */
92     KIO::filesize_t available() const;
93 
94     /**
95      * The used space in the partition mounted at mountPoint()
96      *
97      * Only valid if isValid() returns \p true.
98      *
99      * \return Used space on the requested partition in bytes.
100      */
101     KIO::filesize_t used() const;
102 
103     /**
104      * Static method used to determine the free disk space.
105      *
106      * \param path An arbitrary path. The available space will be
107      * determined for the partition containing path.
108      *
109      * Check isValid() to see if the process was successful. Then
110      * use mountPoint(), size(), available(), and used() to access
111      * the requested values.
112      *
113      * @deprecated Since 5.88, use KIO::FileSystemFreeSpaceJob or QStorageInfo instead.
114      */
115     KIOCORE_DEPRECATED_VERSION(5, 88, "Use KIO::FileSystemFreeSpaceJob or QStorageInfo instead.")
116     static KDiskFreeSpaceInfo freeSpaceInfo(const QString &path);
117 
118 private:
119     KDiskFreeSpaceInfo();
120 
121     QSharedDataPointer<KDiskFreeSpaceInfoPrivate> d;
122 };
123 #endif // Deprecation
124 
125 #endif
126