LCOV - code coverage report
Current view: top level - src/engraving/compat - mscxcompat.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 42.9 % 28 12
Test Date: 2026-11-05 04:07:02

            Line data    Source code
       1              : /*
       2              :  * SPDX-License-Identifier: GPL-3.0-only
       3              :  * MuseScore-Studio-CLA-applies
       4              :  *
       5              :  * MuseScore Studio
       6              :  * Music Composition & Notation
       7              :  *
       8              :  * Copyright (C) 2021 MuseScore Limited and others
       9              :  *
      10              :  * This program is free software: you can redistribute it and/or modify
      11              :  * it under the terms of the GNU General Public License version 3 as
      12              :  * published by the Free Software Foundation.
      13              :  *
      14              :  * This program is distributed in the hope that it will be useful,
      15              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      16              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17              :  * GNU General Public License for more details.
      18              :  *
      19              :  * You should have received a copy of the GNU General Public License
      20              :  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
      21              :  */
      22              : #include "mscxcompat.h"
      23              : 
      24              : #include "io/file.h"
      25              : #include "io/buffer.h"
      26              : 
      27              : #include "engraving/engravingerrors.h"
      28              : #include "../rw/mscloader.h"
      29              : 
      30              : #include "infrastructure/localfileinfoprovider.h"
      31              : 
      32              : #include "log.h"
      33              : 
      34              : using namespace muse;
      35              : using namespace muse::io;
      36              : using namespace mu::engraving;
      37              : 
      38         1001 : Ret mu::engraving::compat::loadMsczOrMscx(MasterScore* score, const io::path_t& path, bool ignoreVersionError)
      39              : {
      40         1001 :     std::string suffix = io::suffix(path);
      41              : 
      42         1001 :     MscReader::Params params;
      43         1001 :     params.filePath = path;
      44         1001 :     params.mode = mscIoModeBySuffix(suffix);
      45         1001 :     IF_ASSERT_FAILED(params.mode != MscIoMode::Unknown) {
      46            0 :         return make_ret(Err::FileUnknownType, path);
      47              :     }
      48              : 
      49         1001 :     MscReader reader(params);
      50         1001 :     Ret ret = reader.open();
      51         1001 :     if (!ret) {
      52            0 :         return ret;
      53              :     }
      54              : 
      55         1001 :     score->setFileInfoProvider(std::make_shared<LocalFileInfoProvider>(path));
      56              : 
      57              :     MscLoader scoreReader;
      58         1001 :     return scoreReader.loadMscz(score, reader, nullptr, ignoreVersionError);
      59         1001 : }
      60              : 
      61            0 : Ret mu::engraving::compat::loadMsczOrMscx(EngravingProjectPtr project, const io::path_t& path, bool ignoreVersionError)
      62              : {
      63            0 :     std::string suffix = io::suffix(path);
      64              : 
      65            0 :     MscReader::Params params;
      66            0 :     params.filePath = path;
      67            0 :     params.mode = mscIoModeBySuffix(suffix);
      68            0 :     IF_ASSERT_FAILED(params.mode != MscIoMode::Unknown) {
      69            0 :         return make_ret(Err::FileUnknownType, path);
      70              :     }
      71              : 
      72            0 :     MscReader reader(params);
      73            0 :     Ret ret = reader.open();
      74            0 :     if (!ret) {
      75            0 :         return ret;
      76              :     }
      77              : 
      78            0 :     project->setFileInfoProvider(std::make_shared<LocalFileInfoProvider>(path));
      79              : 
      80            0 :     return project->loadMscz(reader, nullptr, ignoreVersionError);
      81            0 : }
        

Generated by: LCOV version 2.0-1