LCOV - code coverage report
Current view: top level - muse/framework/global/io - ioretcodes.h Coverage Total Hit
Test: filtered_coverage.info Lines: 47.1 % 17 8
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              : #ifndef MUSE_IO_IORETCODES_H
      23              : #define MUSE_IO_IORETCODES_H
      24              : 
      25              : #include "global/types/ret.h"
      26              : #include "global/translation.h"
      27              : 
      28              : namespace muse::io {
      29              : enum class Err {
      30              :     Undefined       = int(Ret::Code::Undefined),
      31              :     NoError         = int(Ret::Code::Ok),
      32              :     UnknownError    = int(Ret::Code::SystemFirst),
      33              : 
      34              :     FSNotExist,
      35              :     FSAlreadyExists,
      36              :     FSRemoveError,
      37              :     FSDirNotEmptyError,
      38              :     FSClearError,
      39              :     FSReadError,
      40              :     FSWriteError,
      41              :     FSMakingError,
      42              :     FSCopyError,
      43              :     FSMoveErrors
      44              : };
      45              : 
      46        20361 : inline Ret make_ret(Err e)
      47              : {
      48        20361 :     int retCode = static_cast<int>(e);
      49              : 
      50        20361 :     switch (e) {
      51            0 :     case Err::Undefined: return Ret(retCode);
      52        17753 :     case Err::NoError: return Ret(retCode);
      53            0 :     case Err::UnknownError: return Ret(retCode);
      54         2602 :     case Err::FSNotExist: return Ret(retCode, muse::trc("system", "The file does not exist"));
      55            0 :     case Err::FSAlreadyExists: return Ret(retCode, muse::trc("system", "The file already exists"));
      56            0 :     case Err::FSRemoveError: return Ret(retCode, muse::trc("system", "The file could not be removed"));
      57            1 :     case Err::FSDirNotEmptyError: return Ret(retCode, muse::trc("system", "The directory is not empty"));
      58            0 :     case Err::FSClearError: return Ret(retCode, muse::trc("system", "The directory could not be cleared"));
      59            4 :     case Err::FSReadError: return Ret(retCode, muse::trc("system", "An error occurred when reading from the file"));
      60            1 :     case Err::FSWriteError: return Ret(retCode, muse::trc("system", "An error occurred when writing to the file"));
      61            0 :     case Err::FSMakingError: return Ret(retCode, muse::trc("system", "An error occurred when making a path"));
      62            0 :     case Err::FSCopyError: return Ret(retCode, muse::trc("system", "An error occurred when copying the file"));
      63            0 :     case Err::FSMoveErrors: return Ret(retCode, muse::trc("system", "An error occurred when moving the file"));
      64              :     }
      65              : 
      66            0 :     return Ret(static_cast<int>(e));
      67              : }
      68              : }
      69              : 
      70              : #endif // MUSE_IO_IORETCODES_H
        

Generated by: LCOV version 2.0-1