Skip to content

Commit

Permalink
mytharchivehelper/main.cpp: use FileSystemInfo
Browse files Browse the repository at this point in the history
instead of duplicating its code.
  • Loading branch information
ulmus-scott committed Feb 16, 2022
1 parent d2e2ad9 commit 0d179c8
Showing 1 changed file with 2 additions and 23 deletions.
25 changes: 2 additions & 23 deletions mythplugins/mytharchive/mytharchivehelper/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@
#include <sys/wait.h> // for WIFEXITED and WEXITSTATUS
#include <unistd.h>

#include <QtGlobal>
#if defined(Q_OS_DARWIN) or defined(__FreeBSD__)
#include <sys/param.h>
#include <sys/mount.h>
#elif defined(__linux__)
#include <sys/vfs.h>
#endif

// Qt headers
#include <QApplication>
#include <QFile>
Expand All @@ -49,9 +41,9 @@
#include <QTextStream>

// MythTV headers
#include <filesysteminfo.h>
#include <mythcommandlineparser.h>
#include <mythmiscutil.h>
#include <mythcoreutil.h>
#include <mythcontext.h>
#include <mythversion.h>
#include <exitcodes.h>
Expand Down Expand Up @@ -2237,21 +2229,8 @@ static int isRemote(const QString& filename)
if (!QFile::exists(filename))
return 0;

// TODO replace with FileSystemInfo?
#ifdef Q_OS_DARWIN
struct statfs statbuf {};
if ((statfs(qPrintable(filename), &statbuf) == 0) &&
((!strcmp(statbuf.f_fstypename, "nfs")) || // NFS|FTP
(!strcmp(statbuf.f_fstypename, "afpfs")) || // ApplShr
(!strcmp(statbuf.f_fstypename, "smbfs")))) // SMB
if (!FileSystemInfo(QString(), filename).isLocal())
return 2;
#elif defined(__linux__)
struct statfs statbuf {};
if ((statfs(qPrintable(filename), &statbuf) == 0) &&
((statbuf.f_type == 0x6969) || // NFS
(statbuf.f_type == 0x517B))) // SMB
return 2;
#endif

return 1;
}
Expand Down

0 comments on commit 0d179c8

Please sign in to comment.