D29128: Search for exercises in XDG_DATA_DIRS for macos

Tomaz Canabrava noreply at phabricator.kde.org
Sat Apr 25 17:52:23 BST 2020

tcanabrava added a comment.

  QList<QString> populateDirs() {
    QList<QString> jsonDirs;
    const QString xdgDataDirsEnv = QFile::decodeName(qgetenv("XDG_DATA_DIRS"));
    if (xdgDataDirsEnv.isEmpty()) {
    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();

  R163 Minuet


To: patrickelectric, sandroandrade
Cc: tcanabrava, kde-edu, cedricbonhomme, narvaez, sandroandrade, apol
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-edu/attachments/20200425/c4cef070/attachment.html>

More information about the kde-edu mailing list