D29128: Search for exercises in XDG_DATA_DIRS for macos

Tomaz Canabrava <[email protected]>
Newsgroups gmane.comp.kde.devel.education
Message-ID <0e003d5dbc69bd79bc8cfc90bf04c067__16995.1372475893$1587833575$gmane$org@localhost.localdomain>
tcanabrava added a comment.


  QList<QString> populateDirs() {
  
    QList<QString> jsonDirs;
    const QString xdgDataDirsEnv = QFile::decodeName(qgetenv("XDG_DATA_DIRS"));
    if (xdgDataDirsEnv.isEmpty()) {
        return;
    }
    const auto parts = xdgDataDirsEnv.splitRef(QLatin1Char(':'), QString::SkipEmptyParts);
    // Normalize paths, skip relative paths
    for (const QStringRef &dir : parts) {
        if (dir.startsWith(QLatin1Char('/'))) {
            const QDir testDir(QDir(dir.toString()).absoluteFilePath(QStringLiteral("minuet/") + directoryName));
            if (testDir.exists()) {
                jsonDirs << testDir.absolutePath();
            }
        }
    }
    return jsonDirs;
  
  }
  
  #ifdef Q_OS_MACOS
  
    // Qt does not check XDG_DATA_DIRS for MACOS but KDE prefix.sh script sets it.
    // If AppDataLocation fail, we should give a shot and check XDG env variable
    if (jsonDirs.isEmpty()) {
            jsonDirs << populateDirs();
    }
  
  #endif
  
  ?

REPOSITORY
  R163 Minuet

REVISION DETAIL
  https://phabricator.kde.org/D29128

To: patrickelectric, sandroandrade
Cc: tcanabrava, kde-edu, cedricbonhomme, narvaez, sandroandrade, apol
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.