LCOV - code coverage report
Current view: top level - muse/framework/extensions/internal - extensionbundle.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 91.7 % 12 11
Test Date: 2026-11-05 04:07:02

            Line data    Source code
       1              : /*
       2              :  * SPDX-License-Identifier: GPL-3.0-only
       3              :  * MuseScore/Audacity CLA applies
       4              :  *
       5              :  * Copyright (C) MuseScore/Audacity and others
       6              :  *
       7              :  * This program is free software: you can redistribute it and/or modify
       8              :  * it under the terms of the GNU General Public License version 3 as
       9              :  * published by the Free Software Foundation.
      10              :  *
      11              :  * This program is distributed in the hope that it will be useful,
      12              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      13              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14              :  * GNU General Public License for more details.
      15              :  *
      16              :  * You should have received a copy of the GNU General Public License
      17              :  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
      18              :  */
      19              : #include "../extensionbundle.h"
      20              : 
      21              : #include <QDir>
      22              : #include <QFileInfo>
      23              : 
      24              : namespace muse::extensions {
      25            2 : std::optional<io::path_t> resolveBundleFile(const io::path_t& bundlePath, const io::path_t& relativePath)
      26              : {
      27            2 :     const QFileInfo declared(relativePath.toQString());
      28            2 :     if (relativePath.empty() || declared.isAbsolute()) {
      29            0 :         return std::nullopt;
      30              :     }
      31              : 
      32            2 :     const QFileInfo bundle(bundlePath.toQString());
      33            2 :     const QString root = bundle.canonicalFilePath();
      34            2 :     const QFileInfo file(QDir(root).filePath(declared.filePath()));
      35            2 :     const QString path = file.canonicalFilePath();
      36            2 :     if (!bundle.isDir() || root.isEmpty() || path.isEmpty() || !file.isFile() || !path.startsWith(root + QLatin1Char('/'))) {
      37            1 :         return std::nullopt;
      38              :     }
      39            1 :     return io::path_t(path);
      40            2 : }
      41              : } // namespace muse::extensions
        

Generated by: LCOV version 2.0-1