mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kio: format and indent
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
5fb662785b
commit
288498df73
2 changed files with 18 additions and 25 deletions
|
@ -24,8 +24,8 @@
|
|||
|
||||
#include "kdiskfreespaceinfo.h"
|
||||
|
||||
#include <QtCore/QSharedData>
|
||||
#include <QtCore/QFile>
|
||||
#include <QSharedData>
|
||||
#include <QFile>
|
||||
|
||||
#include <kmountpoint.h>
|
||||
#include <kdebug.h>
|
||||
|
@ -38,8 +38,9 @@ class KDiskFreeSpaceInfo::Private : public QSharedData
|
|||
public:
|
||||
Private()
|
||||
: valid(false),
|
||||
size(0),
|
||||
available(0) {
|
||||
size(0),
|
||||
available(0)
|
||||
{
|
||||
}
|
||||
|
||||
bool valid;
|
||||
|
@ -54,31 +55,26 @@ KDiskFreeSpaceInfo::KDiskFreeSpaceInfo()
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
KDiskFreeSpaceInfo::KDiskFreeSpaceInfo( const KDiskFreeSpaceInfo& other )
|
||||
KDiskFreeSpaceInfo::KDiskFreeSpaceInfo(const KDiskFreeSpaceInfo &other)
|
||||
{
|
||||
d = other.d;
|
||||
}
|
||||
|
||||
|
||||
KDiskFreeSpaceInfo::~KDiskFreeSpaceInfo()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
KDiskFreeSpaceInfo& KDiskFreeSpaceInfo::operator=( const KDiskFreeSpaceInfo& other )
|
||||
KDiskFreeSpaceInfo& KDiskFreeSpaceInfo::operator=(const KDiskFreeSpaceInfo &other)
|
||||
{
|
||||
d = other.d;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
bool KDiskFreeSpaceInfo::isValid() const
|
||||
{
|
||||
return d->valid;
|
||||
}
|
||||
|
||||
|
||||
QString KDiskFreeSpaceInfo::mountPoint() const
|
||||
{
|
||||
return d->mountPoint;
|
||||
|
@ -90,37 +86,34 @@ KIO::filesize_t KDiskFreeSpaceInfo::size() const
|
|||
return d->size;
|
||||
}
|
||||
|
||||
|
||||
KIO::filesize_t KDiskFreeSpaceInfo::available() const
|
||||
{
|
||||
return d->available;
|
||||
}
|
||||
|
||||
|
||||
KIO::filesize_t KDiskFreeSpaceInfo::used() const
|
||||
{
|
||||
return d->size - d->available;
|
||||
return (d->size - d->available);
|
||||
}
|
||||
|
||||
|
||||
KDiskFreeSpaceInfo KDiskFreeSpaceInfo::freeSpaceInfo( const QString& path )
|
||||
KDiskFreeSpaceInfo KDiskFreeSpaceInfo::freeSpaceInfo(const QString &path)
|
||||
{
|
||||
KDiskFreeSpaceInfo info;
|
||||
|
||||
// determine the mount point
|
||||
KMountPoint::Ptr mp = KMountPoint::currentMountPoints().findByPath( path );
|
||||
if (mp)
|
||||
KMountPoint::Ptr mp = KMountPoint::currentMountPoints().findByPath(path);
|
||||
if (mp) {
|
||||
info.d->mountPoint = mp->mountPoint();
|
||||
}
|
||||
|
||||
struct statvfs statvfs_buf;
|
||||
|
||||
// Prefer mountPoint if available, so that it even works with non-existing files.
|
||||
const QString pathArg = info.d->mountPoint.isEmpty() ? path : info.d->mountPoint;
|
||||
const QString pathArg = (info.d->mountPoint.isEmpty() ? path : info.d->mountPoint);
|
||||
const QByteArray pathArgBytes = QFile::encodeName(pathArg);
|
||||
if (::statvfs(pathArgBytes.constData(), &statvfs_buf) == 0) {
|
||||
const quint64 blksize = quint64(statvfs_buf.f_frsize); // cast to avoid overflow
|
||||
info.d->available = statvfs_buf.f_bavail * blksize;
|
||||
info.d->size = statvfs_buf.f_blocks * blksize;
|
||||
info.d->available = (statvfs_buf.f_bavail * blksize);
|
||||
info.d->size = (statvfs_buf.f_blocks * blksize);
|
||||
info.d->valid = true;
|
||||
} else {
|
||||
const int savederrno = errno;
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
/**
|
||||
* Copy constructor
|
||||
*/
|
||||
KDiskFreeSpaceInfo( const KDiskFreeSpaceInfo& );
|
||||
KDiskFreeSpaceInfo(const KDiskFreeSpaceInfo &other);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
|
@ -65,7 +65,7 @@ public:
|
|||
/**
|
||||
* Assignment operator
|
||||
*/
|
||||
KDiskFreeSpaceInfo& operator=( const KDiskFreeSpaceInfo& );
|
||||
KDiskFreeSpaceInfo& operator=(const KDiskFreeSpaceInfo &other);
|
||||
|
||||
/**
|
||||
* \return \p true if the available disk space was successfully
|
||||
|
@ -118,7 +118,7 @@ public:
|
|||
* use mountPoint(), size(), available(), and used() to access
|
||||
* the requested values.
|
||||
*/
|
||||
static KDiskFreeSpaceInfo freeSpaceInfo( const QString& path );
|
||||
static KDiskFreeSpaceInfo freeSpaceInfo(const QString &path);
|
||||
|
||||
private:
|
||||
KDiskFreeSpaceInfo();
|
||||
|
|
Loading…
Add table
Reference in a new issue