LCOV - code coverage report
Current view: top level - muse/framework/draw/utils - drawdatarw.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 14.3 % 28 4
Test Date: 2026-11-05 04:07:02

            Line data    Source code
       1              : /*
       2              :  * SPDX-License-Identifier: GPL-3.0-only
       3              :  * MuseScore-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 "drawdatarw.h"
      23              : 
      24              : #include "global/io/file.h"
      25              : #include "drawdatajson.h"
      26              : 
      27              : #include "log.h"
      28              : 
      29              : using namespace muse;
      30              : using namespace muse::draw;
      31              : 
      32            0 : RetVal<DrawDataPtr> DrawDataRW::readData(const io::path_t& filePath)
      33              : {
      34            0 :     ByteArray json;
      35            0 :     Ret ret = io::File::readFile(filePath, json);
      36            0 :     if (!ret) {
      37            0 :         return RetVal<DrawDataPtr>(ret);
      38              :     }
      39              : 
      40            0 :     RetVal<DrawDataPtr> rv = DrawDataJson::fromJson(json);
      41            0 :     return rv;
      42            0 : }
      43              : 
      44           10 : Ret DrawDataRW::writeData(const io::path_t& filePath, const DrawDataPtr& data, bool prettify)
      45              : {
      46           10 :     ByteArray json = DrawDataJson::toJson(data, prettify);
      47           20 :     return io::File::writeFile(filePath, json);
      48           10 : }
      49              : 
      50            0 : RetVal<Diff> DrawDataRW::readDiff(const io::path_t& filePath)
      51              : {
      52            0 :     ByteArray json;
      53            0 :     Ret ret = io::File::readFile(filePath, json);
      54            0 :     if (!ret) {
      55            0 :         return RetVal<Diff>(ret);
      56              :     }
      57              : 
      58            0 :     RetVal<Diff> rv = DrawDataJson::diffFromJson(json);
      59            0 :     return rv;
      60            0 : }
      61              : 
      62            0 : Ret DrawDataRW::writeDiff(const io::path_t& filePath, const Diff& diff)
      63              : {
      64            0 :     ByteArray json = DrawDataJson::diffToJson(diff);
      65            0 :     Ret ret = io::File::writeFile(filePath, json);
      66            0 :     if (ret) {
      67            0 :         LOGI() << "success write diff, file: " << filePath;
      68              :     } else {
      69            0 :         LOGE() << "failed write diff, err: " << ret.toString() << ", file: " << filePath;
      70              :     }
      71            0 :     return ret;
      72            0 : }
        

Generated by: LCOV version 2.0-1