Skip to content

Commit 7aaae3a

Browse files
committed
filesysteminfo.cpp: move functions together
based on namespace or class.
1 parent 76bade8 commit 7aaae3a

File tree

1 file changed

+43
-44
lines changed

1 file changed

+43
-44
lines changed

mythtv/libs/libmythbase/filesysteminfo.cpp

+43-44
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,49 @@ bool FileSystemInfo::FromStringList(QStringList::const_iterator &it,
9797
return true;
9898
}
9999

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+
100143
// default: sock = nullptr
101144
FileSystemInfoList FileSystemInfoManager::GetInfoList(MythSocket *sock)
102145
{
@@ -161,50 +204,6 @@ void FileSystemInfoManager::Consolidate(FileSystemInfoList &disks,
161204
}
162205
}
163206

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-
208207
FileSystemInfoList FileSystemInfoManager::FromStringList(const QStringList& list)
209208
{
210209
FileSystemInfoList fsInfos;

0 commit comments

Comments
 (0)