lmms
Cross-platform music production software
Loading...
Searching...
No Matches
PathUtil.h
Go to the documentation of this file.
1/*
2 * PathUtil.h
3 *
4 * Copyright (c) 2019-2022 Spekular <Spekularr@gmail.com>
5 *
6 * This file is part of LMMS - https://lmms.io
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program (see COPYING); if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301 USA.
22 *
23 */
24
25#ifndef LMMS_PATHUTIL_H
26#define LMMS_PATHUTIL_H
27
28#include <filesystem>
29#include <string_view>
30
31#include <QDir>
32
33#include "lmms_export.h"
34
35namespace lmms::PathUtil
36{
40
45 QString LMMS_EXPORT baseLocation(const Base base, bool* error = nullptr);
49 QDir LMMS_EXPORT baseQDir (const Base base, bool* error = nullptr);
51 QString LMMS_EXPORT basePrefix(const Base base);
54 Base LMMS_EXPORT baseLookup(const QString& input);
55
57 QString LMMS_EXPORT stripPrefix(const QString& input);
59 QString LMMS_EXPORT cleanName(const QString& input);
60
62 QString LMMS_EXPORT oldRelativeUpgrade(const QString& input);
63
66 QString LMMS_EXPORT toAbsolute(const QString& input, bool* error = nullptr);
68 QString LMMS_EXPORT relativeOrAbsolute(const QString& input, const Base base);
72 QString LMMS_EXPORT toShortestRelative(const QString& input, bool allowLocal = false);
73
75 LMMS_EXPORT auto stringToPath(std::string_view path) -> std::filesystem::path;
76
78 LMMS_EXPORT auto stringToPath(const QString& path) -> std::filesystem::path;
79
81 LMMS_EXPORT auto pathToString(const std::filesystem::path& path) -> std::string;
82} // namespace lmms::PathUtil
83
84#endif // LMMS_PATHUTIL_H
Definition PathUtil.cpp:37
QDir baseQDir(const Base base, bool *error)
Definition PathUtil.cpp:94
QString toAbsolute(const QString &input, bool *error)
Definition PathUtil.cpp:195
QString relativeOrAbsolute(const QString &input, const Base base)
Make this path relative to a given base, return an absolute path if that fails.
Definition PathUtil.cpp:214
Base baseLookup(const QString &input)
Definition PathUtil.cpp:126
auto stringToPath(std::string_view path) -> std::filesystem::path
Converts a UTF-8 encoded string to std::filesystem::path.
Definition PathUtil.cpp:255
auto pathToString(const std::filesystem::path &path) -> std::string
Converts std::filesystem::path to a UTF-8 encoded std::string.
Definition PathUtil.cpp:276
QString stripPrefix(const QString &input)
Remove the prefix from a path, iff there is one.
Definition PathUtil.cpp:149
QString toShortestRelative(const QString &input, bool allowLocal)
Definition PathUtil.cpp:229
QString basePrefix(const Base base)
Return the prefix used to denote this base in path strings.
Definition PathUtil.cpp:104
QString oldRelativeUpgrade(const QString &input)
Upgrade prefix-less relative paths to the new format.
Definition PathUtil.cpp:168
Base
Definition PathUtil.h:37
@ UserLADSPA
Definition PathUtil.h:38
@ UserSoundfont
Definition PathUtil.h:38
@ UserGIG
Definition PathUtil.h:38
@ UserSample
Definition PathUtil.h:37
@ LocalDir
Definition PathUtil.h:39
@ ProjectDir
Definition PathUtil.h:37
@ FactoryPresets
Definition PathUtil.h:38
@ DefaultLADSPA
Definition PathUtil.h:38
@ DefaultSoundfont
Definition PathUtil.h:38
@ FactorySample
Definition PathUtil.h:37
@ Absolute
Definition PathUtil.h:37
@ UserVST
Definition PathUtil.h:37
@ Preset
Definition PathUtil.h:37
@ FactoryProjects
Definition PathUtil.h:37
@ DefaultGIG
Definition PathUtil.h:38
QString cleanName(const QString &input)
Get the filename for a path, handling prefixed paths correctly.
Definition PathUtil.cpp:157
QString baseLocation(const Base base, bool *error)
Definition PathUtil.cpp:42