PathUtil: Serialization and Formatting (#8103)

PathUtil: Serialization and Formatting
* Serialize all operations to use / instead of platform specific paths.
* Formatting changes for consistency.
* Reorder functions, add serialization enforcement to the other two functions.
This commit is contained in:
Jan125
2025-10-31 17:06:34 +01:00
committed by GitHub
parent 0fe697c4e5
commit fcb356df3d
2 changed files with 58 additions and 32 deletions

View File

@@ -48,25 +48,25 @@ namespace lmms::PathUtil
QString LMMS_EXPORT basePrefix(const Base base);
//! Check the prefix of a path and return the base it corresponds to
//! Defaults to Base::Absolute
Base LMMS_EXPORT baseLookup(const QString & path);
Base LMMS_EXPORT baseLookup(const QString& input);
//! Remove the prefix from a path, iff there is one
QString LMMS_EXPORT stripPrefix(const QString & path);
QString LMMS_EXPORT stripPrefix(const QString& input);
//! Get the filename for a path, handling prefixed paths correctly
QString LMMS_EXPORT cleanName(const QString & path);
QString LMMS_EXPORT cleanName(const QString& input);
//! Upgrade prefix-less relative paths to the new format
QString LMMS_EXPORT oldRelativeUpgrade(const QString & input);
QString LMMS_EXPORT oldRelativeUpgrade(const QString& input);
//! Make this path absolute. If a pointer to boolean is given
//! it will indicate whether the path was converted successfully
QString LMMS_EXPORT toAbsolute(const QString & input, bool* error = nullptr);
QString LMMS_EXPORT toAbsolute(const QString& input, bool* error = nullptr);
//! Make this path relative to a given base, return an absolute path if that fails
QString LMMS_EXPORT relativeOrAbsolute(const QString & input, const Base base);
QString LMMS_EXPORT relativeOrAbsolute(const QString& input, const Base base);
//! Make this path relative to any base, choosing the shortest if there are
//! multiple options. allowLocal defines whether local paths should be considered.
//! Defaults to an absolute path if all bases fail.
QString LMMS_EXPORT toShortestRelative(const QString & input, bool allowLocal = false);
QString LMMS_EXPORT toShortestRelative(const QString& input, bool allowLocal = false);
} // namespace lmms::PathUtil