-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQDiskInfo.h
109 lines (97 loc) · 2.42 KB
/
QDiskInfo.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#ifndef QDISKINFO_H
#define QDISKINFO_H
#include <string>
/*
* 文件系统很多,列表如下
ADFS_SUPER_MAGIC 0xadf5
AFFS_SUPER_MAGIC 0xADFF
BEFS_SUPER_MAGIC 0x42465331
BFS_MAGIC 0x1BADFACE
CIFS_MAGIC_NUMBER 0xFF534D42
CODA_SUPER_MAGIC 0x73757245
COH_SUPER_MAGIC 0x012FF7B7
CRAMFS_MAGIC 0x28cd3d45
DEVFS_SUPER_MAGIC 0x1373
EFS_SUPER_MAGIC 0x00414A53
EXT_SUPER_MAGIC 0x137D
EXT2_OLD_SUPER_MAGIC 0xEF51
EXT2_SUPER_MAGIC 0xEF53
EXT3_SUPER_MAGIC 0xEF53
HFS_SUPER_MAGIC 0x4244
HPFS_SUPER_MAGIC 0xF995E849
HUGETLBFS_MAGIC 0x958458f6
ISOFS_SUPER_MAGIC 0x9660
JFFS2_SUPER_MAGIC 0x72b6
JFS_SUPER_MAGIC 0x3153464a
MINIX_SUPER_MAGIC 0x137F
MINIX_SUPER_MAGIC2 0x138F
MINIX2_SUPER_MAGIC 0x2468
MINIX2_SUPER_MAGIC2 0x2478
MSDOS_SUPER_MAGIC 0x4d44
NCP_SUPER_MAGIC 0x564c
NFS_SUPER_MAGIC 0x6969
NTFS_SB_MAGIC 0x5346544e
OPENPROM_SUPER_MAGIC 0x9fa1
PROC_SUPER_MAGIC 0x9fa0
QNX4_SUPER_MAGIC 0x002f
REISERFS_SUPER_MAGIC 0x52654973
ROMFS_MAGIC 0x7275
SMB_SUPER_MAGIC 0x517B
SYSV2_SUPER_MAGIC 0x012FF7B6
SYSV4_SUPER_MAGIC 0x012FF7B5
TMPFS_MAGIC 0x01021994
UDF_SUPER_MAGIC 0x15013346
UFS_MAGIC 0x00011954
USBDEVICE_SUPER_MAGIC 0x9fa2
VXFS_SUPER_MAGIC 0xa501FCF5
XENIX_SUPER_MAGIC 0x012FF7B4
XFS_SUPER_MAGIC 0x58465342
_XIAFS_SUPER_MAGIC 0x012FD16D
*/
typedef enum
{
DISK_FORMAT_FAT,
DISK_FORMAT_NTFS,
DISK_FORMAT_EXT2,
DISK_FORMAT_UNKNOW //其他省略
} DISK_FORMAT;
class QDiskInfo
{
public:
/*
* 设置磁盘目录
*/
QDiskInfo(const std::string &_path = "/data/");
virtual ~QDiskInfo();
/*
* 刷新磁盘信息
* 当磁盘信息发生改变是应当刷新后再获取
*/
void refreshInfo();
/*
* 获取磁盘总大小
* 单位为B
*/
long long getTotalSize();
/*
* 获取磁盘已使用大小
* 单位为B
*/
long long getUsedSize();
/*
* 获取磁盘已使用大小
* 单位为B
*/
long long getLeftSize();
/*
* 获取磁盘文件系统
*/
DISK_FORMAT getDiskFormat();
private:
long long disk_total_capacity;
long long disk_used_capacity;
long long disk_free_capacity;
DISK_FORMAT disk_format;
std::string path;
};
#endif // QDISKINFO_H