Skip to content

files-app does not compile on OSX #30

@nbigaouette

Description

@nbigaouette

There seems to be a mount helper included in files-app but this is not supported under OSX.

Trying to compile it I get the following error:

make
[  2%] Built target translations
[  5%] Automatic moc for target folderlistmodel
[  5%] Built target folderlistmodel_automoc
[ 62%] Built target folderlistmodel
[ 65%] Automatic moc for target PlacesModel
[ 65%] Built target PlacesModel_automoc
[ 67%] Building CXX object src/plugin/placesmodel/CMakeFiles/PlacesModel.dir/qmtabparser.cpp.o
files-app.git/src/plugin/placesmodel/qmtabparser.cpp:22:10: fatal error: 'mntent.h'
      file not found
#include <mntent.h>
         ^
1 error generated.
make[2]: *** [src/plugin/placesmodel/CMakeFiles/PlacesModel.dir/qmtabparser.cpp.o] Error 1
make[1]: *** [src/plugin/placesmodel/CMakeFiles/PlacesModel.dir/all] Error 2
make: *** [all] Error 2

I simply deleted everything related to mtab for files-app to compile:

diff --git a/src/plugin/placesmodel/CMakeLists.txt b/src/plugin/placesmodel/CMakeLists.txt
index 5db402e..69240dd 100644
--- a/src/plugin/placesmodel/CMakeLists.txt
+++ b/src/plugin/placesmodel/CMakeLists.txt
@@ -9,8 +9,6 @@ set(placesmodel_SRCS
     placesmodel.h
     placesmodel_plugin.cpp
     placesmodel_plugin.h
-    qmtabparser.h
-    qmtabparser.cpp
 )

 add_library(PlacesModel MODULE
@@ -34,4 +32,3 @@ endif(NOT "${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
 # Install plugin file
 install(TARGETS PlacesModel DESTINATION ${QT_IMPORTS_DIR}/${PLUGIN_DIR})
 install(FILES qmldir DESTINATION ${QT_IMPORTS_DIR}/${PLUGIN_DIR})
-
diff --git a/src/plugin/placesmodel/placesmodel.cpp b/src/plugin/placesmodel/placesmodel.cpp
index 0e8aed6..a5ade52 100644
--- a/src/plugin/placesmodel/placesmodel.cpp
+++ b/src/plugin/placesmodel/placesmodel.cpp
@@ -62,7 +62,6 @@ PlacesModel::PlacesModel(QObject *parent) :
     }

     initNewUserMountsWatcher();
-    rescanMtab();
 }

 PlacesModel::~PlacesModel() {
@@ -73,77 +72,7 @@ void
 PlacesModel::initNewUserMountsWatcher() {
     m_newUserMountsWatcher = new QFileSystemWatcher(this);

-    qDebug() << Q_FUNC_INFO << "Start watching mtab file for new mounts" << m_mtabParser.path();
-
-    m_newUserMountsWatcher->addPath(m_mtabParser.path());
-
-    connect(m_newUserMountsWatcher, &QFileSystemWatcher::fileChanged, this, &PlacesModel::mtabChanged);
-}
-
-void
-PlacesModel::mtabChanged(const QString &path) {
-    qDebug() << Q_FUNC_INFO << "file changed in " << path;
-    rescanMtab();
-    // Since old mtab file is replaced with new contents, must readd filesystem watcher
-    m_newUserMountsWatcher->removePath(path);
-    m_newUserMountsWatcher->addPath(path);
-}
-
-void
-PlacesModel::rescanMtab() {
-    const QString& path = m_mtabParser.path();
-    qDebug() << Q_FUNC_INFO << "rescanning mtab" << path;
-
-    QList<QMtabEntry> entries = m_mtabParser.parseEntries();
-
-    QSet<QString> userMounts;
-
-    foreach (QMtabEntry e, entries) {
-        qDebug() << Q_FUNC_INFO << "Considering" << "fsName:" <<  e.fsName << "dir:" << e.dir << "type:" << e.type;
-        if (isMtabEntryUserMount(e)) {
-            qDebug() << Q_FUNC_INFO << "Adding as userMount directory dir" << e.dir;
-            userMounts << e.dir;
-        }
-    }
-
-    QSet<QString> addedMounts = QSet<QString>(userMounts).subtract(m_userMounts);
-    QSet<QString> removedMounts = QSet<QString>(m_userMounts).subtract(userMounts);
-
-    m_userMounts = userMounts;
-
-    foreach (QString addedMount, addedMounts) {
-        qDebug() << Q_FUNC_INFO << "user mount added: " << addedMount;
-        addLocationWithoutStoring(addedMount);
-        emit userMountAdded(addedMount);
-    }
-
-    foreach (QString removedMount, removedMounts) {
-        qDebug() << Q_FUNC_INFO << "user mount removed: " << removedMount;
-        int index = m_locations.indexOf(removedMount);
-        if (index > -1) {
-            removeItemWithoutStoring(index);
-        }
-        emit userMountRemoved(removedMount);
-    }
-}
-
-bool PlacesModel::isMtabEntryUserMount(const QMtabEntry &e) const {
-    if (e.fsName == "none") {
-        qDebug() << Q_FUNC_INFO << "Ignoring mounts with filesystem name 'none'";
-        return false;
-    }
-    if (isSubDirectory(m_userMountLocation, e.dir)) {
-        qDebug() << Q_FUNC_INFO << "Is user mount location";
-        return true;
-    }
-    foreach (const QString &runtimeLocation, m_runtimeLocations) {
-        if (isSubDirectory(runtimeLocation, e.dir)) {
-            qDebug() << Q_FUNC_INFO << "Is user mount location";
-            return true;
-        }
-    }
-
-    return false;
+    qDebug() << Q_FUNC_INFO << "mtab disabled on OSX";
 }

 bool PlacesModel::isSubDirectory(const QString &dir, const QString &path) const {
diff --git a/src/plugin/placesmodel/placesmodel.h b/src/plugin/placesmodel/placesmodel.h
index 56156eb..3c1560f 100644
--- a/src/plugin/placesmodel/placesmodel.h
+++ b/src/plugin/placesmodel/placesmodel.h
@@ -28,8 +28,6 @@
 #include <QTimer>
 #include <QSet>

-#include "qmtabparser.h"
-
 class PlacesModel : public QAbstractListModel
 {
     Q_OBJECT
@@ -65,10 +63,6 @@ public slots:
         return m_userMounts.contains(location);
     }

-private slots:
-    void mtabChanged(const QString &path);
-    void rescanMtab();
-
 private:
     void initNewUserMountsWatcher();
     // Returns true if location was not known before, and false if it was known
@@ -76,10 +70,8 @@ private:
     // Returns true if location was not known before, and false if it was known
     void removeItemWithoutStoring(int itemToRemove);

-    QMtabParser m_mtabParser;
     QStringList m_runtimeLocations;
     QString m_userMountLocation;
-    bool isMtabEntryUserMount(const QMtabEntry &entry) const;
     bool isSubDirectory(const QString &dir, const QString &path) const;
     QString standardLocation(QStandardPaths::StandardLocation location) const;
     QStringList m_locations;
@@ -89,6 +81,3 @@ private:
 };

 #endif // PLACESMODEL_H
-
-
-
diff --git a/src/plugin/placesmodel/qmtabparser.cpp b/src/plugin/placesmodel/qmtabparser.cpp
deleted file mode 100644
index 99fe6c0..0000000
--- a/src/plugin/placesmodel/qmtabparser.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2015 Canonical Ltd
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 3 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- * Author : Arto Jalkanen <ajalkane@gmail.com>
- *          Carlos J Mazieri <carlos.mazieri@gmail.com>
- */
-
-#include <qmtabparser.h>
-
-#include <mntent.h>
-
-#include <QFileInfo>
-#include <QStringList>
-
-class MtabFileGuard {
-    FILE *mtabFile;
-
-public:
-    MtabFileGuard(FILE *f) {
-        mtabFile = f;
-    }
-    ~MtabFileGuard() {
-        endmntent(mtabFile);
-    }
-};
-
-QMtabParser::QMtabParser(const QString& path, QObject *parent)
-    : QObject(parent) {
-    m_path = path.isEmpty() ? _PATH_MOUNTED : path;
-}
-
-QMtabParser::~QMtabParser() {}
-
-QList<QMtabEntry>
-QMtabParser::parseEntries() {
-    QList<QMtabEntry> entries;
-
-    FILE *f = setmntent(m_path.toLocal8Bit().data(), "r");
-    if (f == 0) {
-        return entries;
-    }
-
-    MtabFileGuard guard(f);
-
-    struct mntent entStorage;
-    char buffer[1024];
-    while (mntent *ent = getmntent_r(f, &entStorage, buffer, 1024)) {
-        QMtabEntry entry;
-        entry.fsName = ent->mnt_fsname;
-        entry.dir = ent->mnt_dir;
-        entry.type = ent->mnt_type;
-        entry.opts = ent->mnt_opts;
-        entry.freq = ent->mnt_freq;
-        entry.passno = ent->mnt_passno;
-        entries << entry;
-    }
-
-    return entries;
-}
diff --git a/src/plugin/placesmodel/qmtabparser.h b/src/plugin/placesmodel/qmtabparser.h
deleted file mode 100644
index 82aa1c4..0000000
--- a/src/plugin/placesmodel/qmtabparser.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2015 Canonical Ltd
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 3 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- * Author : Arto Jalkanen <ajalkane@gmail.com>
- *          Carlos J Mazieri <carlos.mazieri@gmail.com>
- */
-
-#ifndef QMTABPARSER_H
-#define QMTABPARSER_H
-
-#include <QObject>
-
-struct QMtabEntry {
-    QString fsName;
-    QString dir;
-    QString type;
-    QString opts;
-    int freq;
-    int passno;
-};
-
-class QMtabParser : public QObject
-{
-    Q_OBJECT
-    QString m_path;
-
-public:
-    explicit QMtabParser(const QString& path = QString(), QObject *parent = 0);
-    ~QMtabParser();
-
-    QList<QMtabEntry> parseEntries();
-
-    inline const QString& path() { return m_path; }
-};
-
-#endif // QMTABPARSER_H
-
-
-

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/28146361-files-app-does-not-compile-on-osx?utm_campaign=plugin&utm_content=tracker%2F12543815&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F12543815&utm_medium=issues&utm_source=github).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions