Browse Source

Simplify #if conditions

adaptive-webui-19844
Chocobo1 6 years ago
parent
commit
acdf5363b2
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 14
      src/base/utils/fs.cpp

14
src/base/utils/fs.cpp

@ -315,7 +315,7 @@ bool Utils::Fs::isNetworkFileSystem(const QString &path)
return false; return false;
return (::GetDriveTypeW(volumePath.get()) == DRIVE_REMOTE); return (::GetDriveTypeW(volumePath.get()) == DRIVE_REMOTE);
#else #elif defined(Q_OS_MAC) || defined(Q_OS_OPENBSD)
QString file = path; QString file = path;
if (!file.endsWith('/')) if (!file.endsWith('/'))
file += '/'; file += '/';
@ -324,12 +324,21 @@ bool Utils::Fs::isNetworkFileSystem(const QString &path)
struct statfs buf {}; struct statfs buf {};
if (statfs(file.toLocal8Bit().constData(), &buf) != 0) if (statfs(file.toLocal8Bit().constData(), &buf) != 0)
return false; return false;
#if defined(Q_OS_MAC) || defined(Q_OS_OPENBSD)
// XXX: should we make sure HAVE_STRUCT_FSSTAT_F_FSTYPENAME is defined? // XXX: should we make sure HAVE_STRUCT_FSSTAT_F_FSTYPENAME is defined?
return ((strncmp(buf.f_fstypename, "cifs", sizeof(buf.f_fstypename)) == 0) 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, "nfs", sizeof(buf.f_fstypename)) == 0)
|| (strncmp(buf.f_fstypename, "smbfs", sizeof(buf.f_fstypename)) == 0)); || (strncmp(buf.f_fstypename, "smbfs", sizeof(buf.f_fstypename)) == 0));
#else #else
QString file = path;
if (!file.endsWith('/'))
file += '/';
file += '.';
struct statfs buf {};
if (statfs(file.toLocal8Bit().constData(), &buf) != 0)
return false;
// Magic number references: // Magic number references:
// 1. /usr/include/linux/magic.h // 1. /usr/include/linux/magic.h
// 2. https://github.com/coreutils/coreutils/blob/master/src/stat.c // 2. https://github.com/coreutils/coreutils/blob/master/src/stat.c
@ -343,6 +352,5 @@ bool Utils::Fs::isNetworkFileSystem(const QString &path)
return false; return false;
} }
#endif #endif
#endif
} }
#endif #endif

Loading…
Cancel
Save