MythTV  master
filesysteminfo.h
Go to the documentation of this file.
1 #ifndef DISKINFO_H_
2 #define DISKINFO_H_
3 #define NUMDISKINFOLINES 8
4 
5 #include <cstdint>
6 
7 #include <QList>
8 #include <QString>
9 #include <QStringList>
10 
11 #include "mythbaseexp.h"
12 #include "mythsocket.h"
13 #include "mythcorecontext.h"
14 
16 {
17  public:
18  FileSystemInfo() = default;
19  FileSystemInfo(const FileSystemInfo &other);
20  FileSystemInfo(QString hostname, QString path, bool local, int fsid,
21  int groupid, int blksize, int64_t total, int64_t used);
22  FileSystemInfo(QStringList::const_iterator &it,
23  const QStringList::const_iterator& end);
24  explicit FileSystemInfo(const QStringList &slist);
25 
26  virtual ~FileSystemInfo(void) = default;
27 
28  FileSystemInfo &operator=(const FileSystemInfo &other);
29  virtual void clone(const FileSystemInfo &other);
30  void clear(void);
31 
32  // information gets
33  QString getHostname(void) const { return m_hostname; }
34  QString getPath(void) const { return m_path; }
35  bool isLocal(void) const { return m_local; }
36  int getFSysID(void) const { return m_fsid; }
37  int getGroupID(void) const { return m_grpid; }
38  int getBlockSize(void) const { return m_blksize; }
39  int64_t getTotalSpace(void) const { return m_total; }
40  int64_t getUsedSpace(void) const { return m_used; }
41  int getWeight(void) const { return m_weight; }
42 
43  // reserved space could potentially result in this being negative
44  int64_t getFreeSpace(void) const { return m_total-m_used; }
45 
46  // information puts
47  void setHostname(const QString& hostname) { m_hostname = hostname; }
48  void setPath(const QString& path) { m_path = path; }
49  void setLocal(bool local = true) { m_local = local; }
50  void setFSysID(int id) { m_fsid = id; }
51  void setGroupID(int id) { m_grpid = id; }
52  void setBlockSize(int size) { m_blksize = size; }
53  void setTotalSpace(int64_t size) { m_total = size; }
54  void setUsedSpace(int64_t size) { m_used = size; }
55  void setWeight(int weight) { m_weight = weight; }
56 
57  bool ToStringList(QStringList &slist) const;
58 
59  static QList<FileSystemInfo> RemoteGetInfo(MythSocket *sock=nullptr);
60  static void Consolidate(QList<FileSystemInfo> &disks, bool merge=true,
61  int64_t fuzz=14000);
62  void PopulateDiskSpace(void);
63  void PopulateFSProp(void);
64 
65  private:
66  bool FromStringList(const QStringList &slist);
67  bool FromStringList(QStringList::const_iterator &it,
68  const QStringList::const_iterator& listend);
69 
70  QString m_hostname;
71  QString m_path;
72  bool m_local {false};
73  int m_fsid {-1};
74  int m_grpid {-1};
75  int m_blksize {4096};
76  int64_t m_total {0};
77  int64_t m_used {0};
78  int m_weight {0};
79 };
80 #endif
FileSystemInfo::setUsedSpace
void setUsedSpace(int64_t size)
Definition: filesysteminfo.h:54
FileSystemInfo::m_path
QString m_path
Definition: filesysteminfo.h:71
FileSystemInfo::setGroupID
void setGroupID(int id)
Definition: filesysteminfo.h:51
mythbaseexp.h
FileSystemInfo::getPath
QString getPath(void) const
Definition: filesysteminfo.h:34
FileSystemInfo::isLocal
bool isLocal(void) const
Definition: filesysteminfo.h:35
FileSystemInfo::~FileSystemInfo
virtual ~FileSystemInfo(void)=default
FileSystemInfo::FileSystemInfo
FileSystemInfo()=default
MythSocket
Class for communcating between myth backends and frontends.
Definition: mythsocket.h:27
FileSystemInfo::setTotalSpace
void setTotalSpace(int64_t size)
Definition: filesysteminfo.h:53
MBASE_PUBLIC
#define MBASE_PUBLIC
Definition: mythbaseexp.h:15
FileSystemInfo::m_hostname
QString m_hostname
Definition: filesysteminfo.h:70
FileSystemInfo::setLocal
void setLocal(bool local=true)
Definition: filesysteminfo.h:49
FileSystemInfo::getTotalSpace
int64_t getTotalSpace(void) const
Definition: filesysteminfo.h:39
FileSystemInfo::setFSysID
void setFSysID(int id)
Definition: filesysteminfo.h:50
FileSystemInfo::getBlockSize
int getBlockSize(void) const
Definition: filesysteminfo.h:38
clear
static void clear(SettingsMap &cache, SettingsMap &overrides, const QString &myKey)
Definition: mythdb.cpp:845
FileSystemInfo::getGroupID
int getGroupID(void) const
Definition: filesysteminfo.h:37
FileSystemInfo::setPath
void setPath(const QString &path)
Definition: filesysteminfo.h:48
mythcorecontext.h
FileSystemInfo::setWeight
void setWeight(int weight)
Definition: filesysteminfo.h:55
FileSystemInfo::setHostname
void setHostname(const QString &hostname)
Definition: filesysteminfo.h:47
FileSystemInfo
Definition: filesysteminfo.h:16
FileSystemInfo::setBlockSize
void setBlockSize(int size)
Definition: filesysteminfo.h:52
FileSystemInfo::getUsedSpace
int64_t getUsedSpace(void) const
Definition: filesysteminfo.h:40
musicbrainzngs.caa.hostname
string hostname
Definition: caa.py:17
FileSystemInfo::getWeight
int getWeight(void) const
Definition: filesysteminfo.h:41
FileSystemInfo::getFSysID
int getFSysID(void) const
Definition: filesysteminfo.h:36
FileSystemInfo::getHostname
QString getHostname(void) const
Definition: filesysteminfo.h:33
mythsocket.h
FileSystemInfo::getFreeSpace
int64_t getFreeSpace(void) const
Definition: filesysteminfo.h:44