File indexing completed on 2025-02-02 03:49:25
0001 /* 0002 This file is part of the KDE project 0003 SPDX-FileCopyrightText: 2008 Tobias Koenig <tokoe@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef DISCSPACEUTIL_H 0009 #define DISCSPACEUTIL_H 0010 0011 #include <QString> 0012 0013 /** 0014 * A small utility class to access and calculate 0015 * size and usage of mount points. 0016 */ 0017 class DiscSpaceUtil 0018 { 0019 public: 0020 /** 0021 * Creates a new disc space util. 0022 * 0023 * @param directory A directory the util shall work on. 0024 */ 0025 explicit DiscSpaceUtil(const QString &directory); 0026 0027 /** 0028 * Returns the usage of the directory pass in the constructor on this 0029 * mount point in percent. 0030 * 0031 * @param size The current size of the directory. 0032 */ 0033 double usage(qint64 size) const; 0034 0035 /** 0036 * Returns the size of the partition in bytes. 0037 */ 0038 qint64 size() const; 0039 0040 /** 0041 * Returns the mount point of the directory. 0042 */ 0043 QString mountPoint() const; 0044 0045 /** 0046 * Returns the size of the given path in bytes. 0047 */ 0048 static qint64 sizeOfPath(const QString &path); 0049 0050 private: 0051 qint64 mFullSize; 0052 QString mMountPoint; 0053 }; 0054 0055 #endif