23#ifndef H2C_FILESYSTEM_H
24#define H2C_FILESYSTEM_H
27#include <QtCore/QString>
184 static QString
song_path(
const QString& sg_name );
190 static QString
pattern_path(
const QString& dk_name,
const QString& p_name );
351 static bool isSongPathValid(
const QString& sSongPath,
bool bCheckExistance =
false );
374 static bool file_exists(
const QString& path,
bool silent=
false );
380 static bool file_readable(
const QString& path,
bool silent=
false );
386 static bool file_writable(
const QString& path,
bool silent=
false );
398 static bool dir_exists(
const QString& path,
bool silent=
false );
404 static bool dir_readable(
const QString& path,
bool silent=
false );
410 static bool dir_writable(
const QString& path,
bool silent=
false );
417 static bool path_usable(
const QString& path,
bool create=
true,
bool silent=
false );
422 static QString
absolute_path(
const QString& sFilename,
bool bSilent =
false );
434 static bool write_to_file(
const QString& dst,
const QString& content );
443 static bool file_copy(
const QString& src,
const QString& dst,
bool overwrite=
false,
bool bSilent =
false );
451 static bool rm(
const QString& path,
bool recursive=
false,
bool bSilent =
false );
456 static bool mkdir(
const QString& path );
491 static bool rm_fr(
const QString& path,
bool bSilent =
false );
508 static bool check_permissions(
const QString& path,
const int perms,
bool silent );
static Logger * logger()
return the logger instance
Filesystem is a thin layer over QDir, QFile and QFileInfo.
static QStringList song_list()
returns a list of existing songs
static QString __usr_cfg_path
the path to the user config file
static bool file_copy(const QString &src, const QString &dst, bool overwrite=false, bool bSilent=false)
copy a source file to a destination
static QString scripts_dir()
returns user scripts path
static const QString patterns_filter_name
static QString playlist_xsd_path()
returns the path to the playlist pattern XSD (xml schema definition) file
static QString validateFilePath(const QString &sPath)
Takes an arbitrary path, replaces white spaces by underscores and removes all characters apart from l...
static QString demos_dir()
returns system demos path
static QString song_path(const QString &sg_name)
returns user song path, add file extension
static QString ensure_session_compatibility(const QString &sPath)
If Hydrogen is under session management, we support for paths relative to the session folder.
static QString sys_data_path()
returns system data path
static bool dir_readable(const QString &path, bool silent=false)
returns true if the given path is a readable regular directory
file_perms
flags available for check_permissions()
static QString cache_dir()
returns user cache path
static const QString patterns_ext
static bool drumkit_exists(const QString &dk_name)
returns true if the drumkit exists within usable system or user drumkits
static bool check_usr_paths()
returns true if the user path is consistent
static const QString scripts_filter_name
static bool file_executable(const QString &path, bool silent=false)
returns true if the given path is an existing executable regular file
static bool isSongPathValid(const QString &sSongPath, bool bCheckExistance=false)
Checks the path pointing to a .h2song.
static bool drumkit_valid(const QString &dk_path)
returns true if the path contains a usable drumkit
static QString playlist_path(const QString &pl_name)
returns user playlist path, add file extension
static QStringList drumkit_list(const QString &path)
static void setPreferencesOverwritePath(const QString &sPath)
static bool check_permissions(const QString &path, const int perms, bool silent)
static QString usr_config_path()
returns user config path
static QString songs_dir()
returns user songs path
static QString pattern_xsd_path()
returns the path to the pattern XSD (xml schema definition) file
static const QString themes_ext
static QString playlists_dir()
returns user playlist path
static DrumkitType determineDrumkitType(const QString &sPath)
static QString usr_click_file_path()
returns click file path from user directory if exists, otherwise from system
static QString empty_sample_path()
returns system empty sample file path
static QStringList playlist_list()
returns a list of existing playlists
static QString absolute_path(const QString &sFilename, bool bSilent=false)
Convert a direct to an absolute path.
static QString plugins_dir()
returns user plugins path
static bool file_writable(const QString &path, bool silent=false)
returns true if the given path is a possibly writable file (may exist or not)
static QStringList theme_list()
static QString usr_drumkits_dir()
returns user drumkits path
static QString untitled_song_name()
returns untitled song name
static bool check_sys_paths()
returns true if the system path is consistent
static const QString & getPreferencesOverwritePath()
static QStringList ladspa_paths()
returns user ladspa paths
static QStringList drumkit_xsd_legacy_paths()
static QStringList pattern_list()
returns a list of existing patterns
static QString sys_drumkits_dir()
returns system drumkits path
static bool rm(const QString &path, bool recursive=false, bool bSilent=false)
remove a path
static QString drumkit_backup_path(const QString &dk_path)
Create a backup path from a drumkit path.
static QStringList song_list_cleared()
returns a list of existing songs, excluding the autosaved one
static QString usr_theme_dir()
static QString drumkit_xsd_path()
returns the path to the drumkit XSD (xml schema definition) file
static QString doc_dir()
returns documentation path
static const QString scripts_ext
static QStringList usr_drumkit_list()
returns list of usable user drumkits ( see Filesystem::drumkit_list )
static QString repositories_cache_dir()
returns user repository cache path
static bool file_is_under_drumkit(const QString &fname)
Checks if the given filepath is under an existing user or system drumkit path, not the existence of t...
static QString prepare_sample_path(const QString &fname)
Returns the basename if the given path is under an existing user or system drumkit path,...
static bool rm_fr(const QString &path, bool bSilent=false)
recursively remove a path
static bool dir_writable(const QString &path, bool silent=false)
returns true if the given path is a writable regular directory
static int get_basename_idx_under_drumkit(const QString &fname)
Returns the index of the basename if the given path is under an existing user or system drumkit path,...
static QString img_dir()
returns gui image path
static QString rerouteDrumkitPath(const QString &sDrumkitPath)
Reroutes stored drumkit paths pointing to a temporary AppImage system data folder to the current AppI...
static bool file_exists(const QString &path, bool silent=false)
returns true if the given path is an existing regular file
static QString __usr_data_path
the path to the user files
static QString empty_song_path()
Provides the full path to the current empty song.
Lookup
Whenever a drumkit is loaded by name a collision between a user and a system drumkit carrying the sam...
@ system
Only search the system drumkits.
@ stacked
First, looks in the system drumkits and, afterwards, in the user drumkits.
@ user
Only search the user drumkits.
static QString drumkit_dir_search(const QString &dk_name, Lookup lookup)
returns the directory holding the named drumkit searching within user then system drumkits
static QString m_sPreferencesOverwritePath
If this variable is non-empty, its content will be used as an alternative to store and load the prefe...
static QString click_file_path()
Returns a string containing the path to the click.wav file used in the metronome.
static QStringList sys_drumkit_list()
returns list of usable system drumkits ( see Filesystem::drumkit_list )
static QString drumkit_path_search(const QString &dk_name, Lookup lookup=Lookup::stacked, bool bSilent=false)
Returns the path to a H2Core::Drumkit folder.
static const QString playlists_filter_name
static QString sys_config_path()
returns system config path
static bool mkdir(const QString &path)
create a path
static QString drumkit_file(const QString &dk_path)
returns the path to the xml file within a supposed drumkit path
static QStringList pattern_drumkits()
returns a list of existing drumkit sub dir into the patterns directory
static QString __sys_data_path
Path to the system files set in Filesystem::bootstrap().
static bool bootstrap(Logger *logger, const QString &sys_path=nullptr)
check user and system filesystem usability
static QString pattern_path(const QString &dk_name, const QString &p_name)
returns user patterns path, add file extension
static QString __usr_log_path
the path to the log file
static bool write_to_file(const QString &dst, const QString &content)
writes to a file
static Logger * __logger
a pointer to the logger
static const QString playlist_ext
static QString i18n_dir()
returns internationalization path
static const QString songs_filter_name
static QString xsd_legacy_dir()
static QString tmp_dir()
returns temp path
DrumkitType
Determines were to find a kit and whether it is writable by the current user.
@ SessionReadWrite
Kit was loaded via a NSM session, OSC command, or CLI option, only persist for the current Hydrogen s...
@ User
Kit was installed by the user, is automatically loaded, and most probably writable.
@ System
Kit was installed with Hydrogen, is automatically loaded, and most probably readonly.
@ SessionReadOnly
Kit was loaded via a NSM session, OSC command, or CLI option, only persist for the current Hydrogen s...
static void info()
send current settings information to logger with INFO severity
static QString usr_data_path()
returns user data path
static QString log_file_path()
returns the full path (including filename) of the logfile
static QString drumkit_usr_path(const QString &dk_name)
returns path for a drumkit within user drumkit path
static const QString drumkit_ext
static const QString themes_filter_name
static const QString songs_ext
static QString sys_theme_dir()
static bool path_usable(const QString &path, bool create=true, bool silent=false)
returns true if the path is a readable and writable regular directory, create if it not exists
static QString drumkit_xml()
Returns filename and extension of the expected drumkit file.
static QString drumkit_xsd()
returns the drumkit XSD (xml schema definition) name
static QString tmp_file_path(const QString &base)
touch a temporary file under tmp_dir() and return it's path.
static QString default_song_name()
Default option to offer the user when saving an empty song to disk.
static QString xsd_dir()
returns system xsd path
static bool song_exists(const QString &sg_name)
returns true if the song file exists
static QStringList __ladspa_paths
paths to laspa plugins
static QString untitled_playlist_file_name()
returns untitled playlist file name
static bool file_readable(const QString &path, bool silent=false)
returns true if the given path is an existing readable regular file
static bool dir_exists(const QString &path, bool silent=false)
returns true if the given path is a regular directory
static QString drumkit_default_kit()
static QString patterns_dir()
returns user patterns path
Class for writing logs to the console.