mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-30 19:40:18 -07:00
Reuse code path
`buf.f_type` should be compatible across platforms. https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/statfs.2.html
This commit is contained in:
parent
1c9321d5a1
commit
5cf39a2970
1 changed files with 12 additions and 13 deletions
|
@ -341,29 +341,27 @@ bool Utils::Fs::isNetworkFileSystem(const QString &path)
|
||||||
if (!::GetVolumePathNameW(pathW.c_str(), volumePath.get(), (path.length() + 1)))
|
if (!::GetVolumePathNameW(pathW.c_str(), volumePath.get(), (path.length() + 1)))
|
||||||
return false;
|
return false;
|
||||||
return (::GetDriveTypeW(volumePath.get()) == DRIVE_REMOTE);
|
return (::GetDriveTypeW(volumePath.get()) == DRIVE_REMOTE);
|
||||||
#elif defined(Q_OS_MACOS) || defined(Q_OS_OPENBSD)
|
|
||||||
QString file = path;
|
|
||||||
if (!file.endsWith('/'))
|
|
||||||
file += '/';
|
|
||||||
file += '.';
|
|
||||||
|
|
||||||
struct statfs buf {};
|
|
||||||
if (statfs(file.toLocal8Bit().constData(), &buf) != 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return ((strncmp(buf.f_fstypename, "cifs", sizeof(buf.f_fstypename)) == 0)
|
|
||||||
|| (strncmp(buf.f_fstypename, "nfs", sizeof(buf.f_fstypename)) == 0)
|
|
||||||
|| (strncmp(buf.f_fstypename, "smbfs", sizeof(buf.f_fstypename)) == 0));
|
|
||||||
#else
|
#else
|
||||||
QString file = path;
|
QString file = path;
|
||||||
if (!file.endsWith('/'))
|
if (!file.endsWith('/'))
|
||||||
file += '/';
|
file += '/';
|
||||||
file += '.';
|
file += '.';
|
||||||
|
|
||||||
|
#if defined(Q_OS_MACOS)
|
||||||
|
struct statfs64 buf {};
|
||||||
|
if (statfs64(file.toLocal8Bit().constData(), &buf) != 0)
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
struct statfs buf {};
|
struct statfs buf {};
|
||||||
if (statfs(file.toLocal8Bit().constData(), &buf) != 0)
|
if (statfs(file.toLocal8Bit().constData(), &buf) != 0)
|
||||||
return false;
|
return false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(Q_OS_OPENBSD)
|
||||||
|
return ((strncmp(buf.f_fstypename, "cifs", sizeof(buf.f_fstypename)) == 0)
|
||||||
|
|| (strncmp(buf.f_fstypename, "nfs", sizeof(buf.f_fstypename)) == 0)
|
||||||
|
|| (strncmp(buf.f_fstypename, "smbfs", sizeof(buf.f_fstypename)) == 0));
|
||||||
|
#else
|
||||||
// Magic number reference:
|
// Magic number reference:
|
||||||
// https://github.com/coreutils/coreutils/blob/master/src/stat.c
|
// https://github.com/coreutils/coreutils/blob/master/src/stat.c
|
||||||
switch (static_cast<quint32>(buf.f_type))
|
switch (static_cast<quint32>(buf.f_type))
|
||||||
|
@ -403,5 +401,6 @@ bool Utils::Fs::isNetworkFileSystem(const QString &path)
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif // Q_OS_HAIKU
|
#endif // Q_OS_HAIKU
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue