@@ -97,6 +97,49 @@ bool FileSystemInfo::FromStringList(QStringList::const_iterator &it,
97
97
return true ;
98
98
}
99
99
100
+ bool FileSystemInfo::refresh ()
101
+ {
102
+ struct statfs statbuf {};
103
+
104
+ // there are cases where statfs will return 0 (good), but f_blocks and
105
+ // others are invalid and set to 0 (such as when an automounted directory
106
+ // is not mounted but still visible because --ghost was used),
107
+ // so check to make sure we can have a total size > 0
108
+ if ((statfs (getPath ().toLocal8Bit ().constData (), &statbuf) == 0 ) &&
109
+ (statbuf.f_blocks > 0 ) && (statbuf.f_bsize > 0 )
110
+ )
111
+ {
112
+ m_total = statbuf.f_blocks * statbuf.f_bsize ;
113
+ // free = statbuf.f_bavail * statbuf.f_bsize;
114
+ m_used = m_total - statbuf.f_bavail * statbuf.f_bsize ;
115
+ m_blksize = statbuf.f_bsize ;
116
+
117
+ // TODO keep as B not KiB
118
+ m_total >>= 10 ;
119
+ m_used >>= 10 ;
120
+
121
+ #ifdef Q_OS_DARWIN
122
+ char *fstypename = statbuf.f_fstypename ;
123
+ m_local = !(
124
+ (strcmp (fstypename, " nfs" ) == 0 ) || // NFS|FTP
125
+ (strcmp (fstypename, " afpfs" ) == 0 ) || // AppleShare
126
+ (strcmp (fstypename, " smbfs" ) == 0 ) // SMB
127
+ );
128
+ #elif defined(__linux__)
129
+ long fstype = statbuf.f_type ;
130
+ m_local = !(
131
+ (fstype == 0x6969 ) || // NFS
132
+ (fstype == 0x517B ) || // SMB
133
+ (fstype == 0xFF534D42L ) // CIFS
134
+ );
135
+ #else
136
+ m_local = true ; // for equivalent behavior
137
+ #endif
138
+ return true ;
139
+ }
140
+ return false ;
141
+ }
142
+
100
143
// default: sock = nullptr
101
144
FileSystemInfoList FileSystemInfoManager::GetInfoList (MythSocket *sock)
102
145
{
@@ -161,50 +204,6 @@ void FileSystemInfoManager::Consolidate(FileSystemInfoList &disks,
161
204
}
162
205
}
163
206
164
- bool FileSystemInfo::refresh ()
165
- {
166
- struct statfs statbuf {};
167
-
168
- // there are cases where statfs will return 0 (good), but f_blocks and
169
- // others are invalid and set to 0 (such as when an automounted directory
170
- // is not mounted but still visible because --ghost was used),
171
- // so check to make sure we can have a total size > 0
172
- if ((statfs (getPath ().toLocal8Bit ().constData (), &statbuf) == 0 ) &&
173
- (statbuf.f_blocks > 0 ) && (statbuf.f_bsize > 0 )
174
- )
175
- {
176
- m_total = statbuf.f_blocks * statbuf.f_bsize ;
177
- // free = statbuf.f_bavail * statbuf.f_bsize;
178
- m_used = m_total - statbuf.f_bavail * statbuf.f_bsize ;
179
- m_blksize = statbuf.f_bsize ;
180
-
181
- // TODO keep as B not KiB
182
- m_total >>= 10 ;
183
- m_used >>= 10 ;
184
-
185
- #ifdef Q_OS_DARWIN
186
- char *fstypename = statbuf.f_fstypename ;
187
- m_local = !(
188
- (strcmp (fstypename, " nfs" ) == 0 ) || // NFS|FTP
189
- (strcmp (fstypename, " afpfs" ) == 0 ) || // AppleShare
190
- (strcmp (fstypename, " smbfs" ) == 0 ) // SMB
191
- );
192
- #elif defined(__linux__)
193
- long fstype = statbuf.f_type ;
194
- m_local = !(
195
- (fstype == 0x6969 ) || // NFS
196
- (fstype == 0x517B ) || // SMB
197
- (fstype == 0xFF534D42L ) // CIFS
198
- );
199
- #else
200
- m_local = true ; // for equivalent behavior
201
- #endif
202
- return true ;
203
- }
204
- return false ;
205
- }
206
-
207
-
208
207
FileSystemInfoList FileSystemInfoManager::FromStringList (const QStringList& list)
209
208
{
210
209
FileSystemInfoList fsInfos;
0 commit comments