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
void setTotalSpace(int64_t size)
void setBlockSize(int size)
QString m_hostname
void setGroupID(int id)
void setWeight(int weight)
int getGroupID(void) const
#define MBASE_PUBLIC
Definition: mythbaseexp.h:15
QString getHostname(void) const
int getWeight(void) const
static void clear(SettingsMap &cache, SettingsMap &overrides, const QString &myKey)
Definition: mythdb.cpp:830
void setFSysID(int id)
string hostname
Definition: caa.py:17
int64_t getFreeSpace(void) const
int64_t getTotalSpace(void) const
int64_t getUsedSpace(void) const
QString getPath(void) const
int getFSysID(void) const
void setUsedSpace(int64_t size)
bool isLocal(void) const
Class for communcating between myth backends and frontends.
Definition: mythsocket.h:26
void setHostname(const QString &hostname)
void setLocal(bool local=true)
void setPath(const QString &path)
int getBlockSize(void) const