LCOV - code coverage report
Current view: top level - muse/framework/global/io - dir.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 73.9 % 23 17
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 "dir.h"
      23              : 
      24              : using namespace muse;
      25              : using namespace muse::io;
      26              : 
      27         1208 : Dir::Dir(const path_t& path)
      28         1208 :     : m_path(path)
      29              : {
      30         1208 : }
      31              : 
      32          142 : path_t Dir::path() const
      33              : {
      34          142 :     return m_path;
      35              : }
      36              : 
      37         1040 : path_t Dir::absolutePath() const
      38              : {
      39         1040 :     return fileSystem()->absoluteFilePath(m_path);
      40              : }
      41              : 
      42           24 : bool Dir::exists() const
      43              : {
      44           24 :     return fileSystem()->exists(m_path);
      45              : }
      46              : 
      47            2 : Ret Dir::removeRecursively()
      48              : {
      49            2 :     return fileSystem()->remove(m_path);
      50              : }
      51              : 
      52            0 : Ret Dir::mkpath()
      53              : {
      54            0 :     return mkpath(m_path);
      55              : }
      56              : 
      57           21 : Ret Dir::mkpath(const path_t& path)
      58              : {
      59           21 :     return fileSystem()->makePath(path);
      60              : }
      61              : 
      62          154 : RetVal<io::paths_t> Dir::scanFiles(const io::path_t& rootDir, const std::vector<std::string>& filters, ScanMode mode)
      63              : {
      64          154 :     return fileSystem()->scanFiles(rootDir, filters, mode);
      65              : }
      66              : 
      67        20700 : path_t Dir::fromNativeSeparators(const path_t& pathName)
      68              : {
      69              : #if defined(Q_OS_WIN)
      70              :     String path = pathName.toString();
      71              :     size_t i = path.indexOf(u'\\');
      72              :     if (i != muse::nidx) {
      73              :         String n(path);
      74              :         if (n.startsWith(u"\\\\?\\")) {
      75              :             n.remove(0, 4);
      76              :             i = n.indexOf(u'\\');
      77              :             if (i == muse::nidx) {
      78              :                 return n;
      79              :             }
      80              :         }
      81              : 
      82              :         for (i = 0; i < n.size(); ++i) {
      83              :             if (n.at(i) == u'\\') {
      84              :                 n[i] = u'/';
      85              :             }
      86              :         }
      87              : 
      88              :         return n;
      89              :     }
      90              : #endif
      91        20700 :     return pathName;
      92              : }
      93              : 
      94            0 : path_t Dir::cleanPath(const path_t& path)
      95              : {
      96            0 :     return fileSystem()->cleanPath(path);
      97              : }
      98              : 
      99            0 : path_t Dir::tempPath()
     100              : {
     101            0 :     return fileSystem()->temporaryDirectoryPath();
     102              : }
        

Generated by: LCOV version 2.0-1