mirror of
https://github.com/LMMS/lmms.git
synced 2026-01-29 00:33:31 -05:00
* Create PathUtils * Replace old SampleBuffer calls * Fix automatic track names * Fix things * Remove accidental duplicate file * Add includes * More incldues * PhysSong's code review + style * Fix vestige loading? Seems more reasonable to convert from relative on load and to relative on save than vice versa. * Typo fix * More Bases * Enable more bases * Add missing semicolons in prefixes * Nicer sample track tooltip * Use correct directories "userXDir" gives the default dir for ladspa, sf2, and gig. "xDir" gives the user dir. * Make relative to both default and custom locations Part 1 * Make relative to both default and custom locations Part 2 * Typofix * Typofix * Fix upgrade function after base renaming * Fix Tests * Update tests/src/core/RelativePathsTest.cpp Co-Authored-By: Hyunjin Song <tteu.ingog@gmail.com> * Choose UserXBase over DefaultXBase if identical toShortestRelative sticks with the first base found if two bases give the same path length. By placing UserXBase Bases before DefaultXBase Bases in the relativeBases vector, toShortestRelative will prioritize them. * Ensure baseLocation always has trailing slash Otherwise, a user configuring a path without one will break things. * Move loc declaration out of switch * Semicolon * Apply suggestions from code review... * Include PathUtil and sort includes * More granular includes * Apply suggestions from code review Co-Authored-By: Hyunjin Song <tteu.ingog@gmail.com> * Update include/PathUtil.h * Leave empty paths alone * Fix stupid merge * Really fix merge. Hopefully * Switch Base from enum to class enum * Don't pass Base by reference * Use QStringLiteral for static QString allocation in basePrefix method * Make VST loading more similar to previous implementation * Fix tests after enum change * Attempt to fix VST loading, nicer name for sample clips * Fix last review comment Don't append a "/" that will be removed by cleanPath later * Apply suggestions from code review Co-authored-by: Dominic Clark <mrdomclark@gmail.com> Co-authored-by: Hyunjin Song <tteu.ingog@gmail.com> Co-authored-by: Dominic Clark <mrdomclark@gmail.com>
42 lines
1.6 KiB
C++
42 lines
1.6 KiB
C++
#ifndef PATHUTIL_H
|
|
#define PATHUTIL_H
|
|
|
|
#include "lmms_export.h"
|
|
|
|
#include <QDir>
|
|
|
|
namespace PathUtil
|
|
{
|
|
enum class Base { Absolute, ProjectDir, FactorySample, UserSample, UserVST, Preset,
|
|
UserLADSPA, DefaultLADSPA, UserSoundfont, DefaultSoundfont, UserGIG, DefaultGIG };
|
|
|
|
//! Return the directory associated with a given base as a QString
|
|
QString LMMS_EXPORT baseLocation(const Base base);
|
|
//! Return the directory associated with a given base as a QDir
|
|
QDir LMMS_EXPORT baseQDir (const Base base);
|
|
//! Return the prefix used to denote this base in path strings
|
|
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);
|
|
|
|
//! Remove the prefix from a path, iff there is one
|
|
QString LMMS_EXPORT stripPrefix(const QString & path);
|
|
//! Get the filename for a path, handling prefixed paths correctly
|
|
QString LMMS_EXPORT cleanName(const QString & path);
|
|
|
|
//! Upgrade prefix-less relative paths to the new format
|
|
QString LMMS_EXPORT oldRelativeUpgrade(const QString & input);
|
|
|
|
//! Make this path absolute
|
|
QString LMMS_EXPORT toAbsolute(const QString & input);
|
|
//! 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);
|
|
//! Make this path relative to any base, choosing the shortest if there are
|
|
//! multiple options. Defaults to an absolute path if all bases fail.
|
|
QString LMMS_EXPORT toShortestRelative(const QString & input);
|
|
|
|
}
|
|
|
|
#endif
|