hydrogen 1.2.3
Filesystem Class Reference

Filesystem is a thin layer over QDir, QFile and QFileInfo. More...

#include <Filesystem.h>

Inheritance diagram for Filesystem:
Object< Filesystem > Base

Public Types

enum class  DrumkitType { System = 0 , User = 1 , SessionReadOnly = 2 , SessionReadWrite = 3 }
 Determines were to find a kit and whether it is writable by the current user. More...
 
enum  file_perms {
  is_dir =0x01 , is_file =0x02 , is_readable =0x04 , is_writable =0x08 ,
  is_executable =0x10
}
 flags available for check_permissions() More...
 
enum class  Lookup { stacked = 0 , user = 1 , system = 2 }
 Whenever a drumkit is loaded by name a collision between a user and a system drumkit carrying the same name can occur. More...
 

Static Public Member Functions

static QString absolute_path (const QString &sFilename, bool bSilent=false)
 Convert a direct to an absolute path.
 
static bool bootstrap (Logger *logger, const QString &sys_path=nullptr)
 check user and system filesystem usability
 
static QString cache_dir ()
 returns user cache path
 
static QString click_file_path ()
 Returns a string containing the path to the click.wav file used in the metronome.
 
static QString default_song_name ()
 Default option to offer the user when saving an empty song to disk.
 
static QString demos_dir ()
 returns system demos path
 
static DrumkitType determineDrumkitType (const QString &sPath)
 
static bool dir_exists (const QString &path, bool silent=false)
 returns true if the given path is a regular directory
 
static bool dir_readable (const QString &path, bool silent=false)
 returns true if the given path is a readable regular directory
 
static bool dir_writable (const QString &path, bool silent=false)
 returns true if the given path is a writable regular directory
 
static QString doc_dir ()
 returns documentation path
 
static QString drumkit_backup_path (const QString &dk_path)
 Create a backup path from a drumkit path.
 
static QString drumkit_default_kit ()
 
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 bool drumkit_exists (const QString &dk_name)
 returns true if the drumkit exists within usable system or user drumkits
 
static QString drumkit_file (const QString &dk_path)
 returns the path to the xml file within a supposed drumkit path
 
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 QString drumkit_usr_path (const QString &dk_name)
 returns path for a drumkit within user drumkit path
 
static bool drumkit_valid (const QString &dk_path)
 returns true if the path contains a usable drumkit
 
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 QStringList drumkit_xsd_legacy_paths ()
 
static QString drumkit_xsd_path ()
 returns the path to the drumkit XSD (xml schema definition) file
 
static QString empty_sample_path ()
 returns system empty sample file path
 
static QString empty_song_path ()
 Provides the full path to the current empty song.
 
static QString ensure_session_compatibility (const QString &sPath)
 If Hydrogen is under session management, we support for paths relative to the session folder.
 
static bool file_copy (const QString &src, const QString &dst, bool overwrite=false, bool bSilent=false)
 copy a source file to a destination
 
static bool file_executable (const QString &path, bool silent=false)
 returns true if the given path is an existing executable regular file
 
static bool file_exists (const QString &path, bool silent=false)
 returns true if the given path is an existing regular file
 
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 the file.
 
static bool file_readable (const QString &path, bool silent=false)
 returns true if the given path is an existing readable regular file
 
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 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, otherwise -1.
 
static const QString & getPreferencesOverwritePath ()
 
static QString i18n_dir ()
 returns internationalization path
 
static QString img_dir ()
 returns gui image path
 
static void info ()
 send current settings information to logger with INFO severity
 
static bool isSongPathValid (const QString &sSongPath, bool bCheckExistance=false)
 Checks the path pointing to a .h2song.
 
static QStringList ladspa_paths ()
 returns user ladspa paths
 
static QString log_file_path ()
 returns the full path (including filename) of the logfile
 
static bool mkdir (const QString &path)
 create a path
 
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 QStringList pattern_drumkits ()
 returns a list of existing drumkit sub dir into the patterns directory
 
static QStringList pattern_list ()
 returns a list of existing patterns
 
static QStringList pattern_list (const QString &path)
 returns a list of existing patterns
 
static QString pattern_path (const QString &dk_name, const QString &p_name)
 returns user patterns path, add file extension
 
static QString pattern_xsd_path ()
 returns the path to the pattern XSD (xml schema definition) file
 
static QString patterns_dir ()
 returns user patterns path
 
static QString patterns_dir (const QString &dk_name)
 returns user patterns path for a specific drumkit
 
static QStringList playlist_list ()
 returns a list of existing playlists
 
static QString playlist_path (const QString &pl_name)
 returns user playlist path, add file extension
 
static QString playlist_xsd_path ()
 returns the path to the playlist pattern XSD (xml schema definition) file
 
static QString playlists_dir ()
 returns user playlist path
 
static QString plugins_dir ()
 returns user plugins path
 
static QString prepare_sample_path (const QString &fname)
 Returns the basename if the given path is under an existing user or system drumkit path, otherwise the given fname.
 
static QString repositories_cache_dir ()
 returns user repository cache path
 
static QString rerouteDrumkitPath (const QString &sDrumkitPath)
 Reroutes stored drumkit paths pointing to a temporary AppImage system data folder to the current AppImage one.
 
static bool rm (const QString &path, bool recursive=false, bool bSilent=false)
 remove a path
 
static QString scripts_dir ()
 returns user scripts path
 
static void setPreferencesOverwritePath (const QString &sPath)
 
static bool song_exists (const QString &sg_name)
 returns true if the song file exists
 
static QStringList song_list ()
 returns a list of existing songs
 
static QStringList song_list_cleared ()
 returns a list of existing songs, excluding the autosaved one
 
static QString song_path (const QString &sg_name)
 returns user song path, add file extension
 
static QString songs_dir ()
 returns user songs path
 
static QString sys_config_path ()
 returns system config path
 
static QString sys_data_path ()
 returns system data path
 
static QStringList sys_drumkit_list ()
 returns list of usable system drumkits ( see Filesystem::drumkit_list )
 
static QString sys_drumkits_dir ()
 returns system drumkits path
 
static QString sys_theme_dir ()
 
static QStringList theme_list ()
 
static QString tmp_dir ()
 returns temp path
 
static QString tmp_file_path (const QString &base)
 touch a temporary file under tmp_dir() and return it's path.
 
static QString untitled_playlist_file_name ()
 returns untitled playlist file name
 
static QString untitled_song_name ()
 returns untitled song name
 
static QString usr_click_file_path ()
 returns click file path from user directory if exists, otherwise from system
 
static QString usr_config_path ()
 returns user config path
 
static QString usr_data_path ()
 returns user data path
 
static QStringList usr_drumkit_list ()
 returns list of usable user drumkits ( see Filesystem::drumkit_list )
 
static QString usr_drumkits_dir ()
 returns user drumkits path
 
static QString usr_theme_dir ()
 
static QString validateFilePath (const QString &sPath)
 Takes an arbitrary path, replaces white spaces by underscores and removes all characters apart from latin characters, arabic numbers, underscores and dashes.
 
static bool write_to_file (const QString &dst, const QString &content)
 writes to a file
 
static QString xsd_dir ()
 returns system xsd path
 
static QString xsd_legacy_dir ()
 
- Static Public Member Functions inherited from Base
static const char * _class_name ()
 return the class name
 
static QString base_clock (const QString &sMsg)
 Measures the current time and stores it in __last_clock.
 
static QString base_clock_in (const QString &sMsg)
 
static int bootstrap (Logger *logger, bool count=false)
 must be called before any Object instantiation !
 
static bool count_active ()
 
static int getAliveObjectCount ()
 
static object_map_t getObjectMap ()
 
static Loggerlogger ()
 return the logger instance
 
static int objects_count ()
 
static void printObjectMapDiff (object_map_t map)
 Creates the difference between a snapshot of the object map and its current state and prints it to std::cout.
 
static void set_count (bool flag)
 enable/disable class instances counting
 
static void write_objects_map_to (std::ostream &out, object_map_t *map=nullptr)
 output the full objects map to a given ostream
 
static void write_objects_map_to_cerr ()
 output objects map to stderr
 

Static Public Attributes

static const QString drumkit_ext = ".h2drumkit"
 
static const QString patterns_ext = ".h2pattern"
 
static const QString patterns_filter_name = "Hydrogen Patterns (*.h2pattern)"
 
static const QString playlist_ext = ".h2playlist"
 
static const QString playlists_filter_name = "Hydrogen Playlists (*.h2playlist)"
 
static const QString scripts_ext = ".sh"
 
static const QString scripts_filter_name = "Hydrogen Scripts (*.sh)"
 
static const QString songs_ext = ".h2song"
 
static const QString songs_filter_name = "Hydrogen Songs (*.h2song)"
 
static const QString themes_ext = ".h2theme"
 
static const QString themes_filter_name = "Hydrogen Theme (*.h2theme)"
 
- Static Public Attributes inherited from Base
static QString sPrintIndention = " "
 String used to format the debugging string output of some core classes.
 

Static Private Member Functions

static bool check_permissions (const QString &path, const int perms, bool silent)
 
static bool check_sys_paths ()
 returns true if the system path is consistent
 
static bool check_usr_paths ()
 returns true if the user path is consistent
 
static QStringList drumkit_list (const QString &path)
 
static bool rm_fr (const QString &path, bool bSilent=false)
 recursively remove a path
 

Static Private Attributes

static QStringList __ladspa_paths
 paths to laspa plugins
 
static Logger__logger = nullptr
 a pointer to the logger
 
static QString __sys_data_path
 Path to the system files set in Filesystem::bootstrap().
 
static QString __usr_cfg_path
 the path to the user config file
 
static QString __usr_data_path
 the path to the user files
 
static QString __usr_log_path = QDir::homePath().append( "/" H2_USR_PATH "/" LOG_FILE)
 the path to the log file
 
static QString m_sPreferencesOverwritePath = ""
 If this variable is non-empty, its content will be used as an alternative to store and load the preferences.
 

Additional Inherited Members

- Public Member Functions inherited from Object< Filesystem >
 Object ()
 
 Object (const Object< Filesystem > &other)
 
- Public Member Functions inherited from Base
 Base ()
 
 Base (const Base &other)
 
virtual const char * class_name () const
 
void Print (bool bShort=true) const
 Prints content of toQString() via DEBUGLOG.
 
virtual QString toQString (const QString &sPrefix="", bool bShort=true) const
 Formatted string version for debugging purposes.
 
- Protected Member Functions inherited from Object< Filesystem >
 ~Object ()
 
- Protected Member Functions inherited from Base
 ~Base ()
 
- Static Protected Member Functions inherited from Base
static void registerClass (const char *name, const atomic_obj_cpt_t *counters)
 
- Static Protected Attributes inherited from Base
static bool __count = false
 should we count class instances
 
static timeval __last_clock = { 0, 0 }
 
static Logger__logger = nullptr
 

Detailed Description

Filesystem is a thin layer over QDir, QFile and QFileInfo.

Definition at line 36 of file Filesystem.h.

Member Enumeration Documentation

◆ DrumkitType

enum class DrumkitType
strong

Determines were to find a kit and whether it is writable by the current user.

Enumerator
System 

Kit was installed with Hydrogen, is automatically loaded, and most probably readonly.

User 

Kit was installed by the user, is automatically loaded, and most probably writable.

SessionReadOnly 

Kit was loaded via a NSM session, OSC command, or CLI option, only persist for the current Hydrogen session, and is readonly.

SessionReadWrite 

Kit was loaded via a NSM session, OSC command, or CLI option, only persist for the current Hydrogen session, and is writable.

Definition at line 70 of file Filesystem.h.

◆ file_perms

enum file_perms

flags available for check_permissions()

Enumerator
is_dir 
is_file 
is_readable 
is_writable 
is_executable 

Definition at line 41 of file Filesystem.h.

◆ Lookup

enum class Lookup
strong

Whenever a drumkit is loaded by name a collision between a user and a system drumkit carrying the same name can occur.

Enumerator
stacked 

First, looks in the system drumkits and, afterwards, in the user drumkits.

In case both sets contain a member sharing the requested name, the user one will override the system one.

This is the way Hydrogen <= 1.1 were handling all look ups.

user 

Only search the user drumkits.

system 

Only search the system drumkits.

Definition at line 53 of file Filesystem.h.

Member Function Documentation

◆ absolute_path()

QString absolute_path ( const QString & sFilename,
bool bSilent = false )
static

Convert a direct to an absolute path.

Definition at line 1002 of file Filesystem.cpp.

◆ bootstrap()

bool bootstrap ( Logger * logger,
const QString & sys_path = nullptr )
static

check user and system filesystem usability

Parameters
loggeris a pointer to the logger instance which will be used
sys_pathan alternate system data path

Definition at line 120 of file Filesystem.cpp.

◆ cache_dir()

QString cache_dir ( )
static

returns user cache path

Definition at line 604 of file Filesystem.cpp.

◆ check_permissions()

bool check_permissions ( const QString & path,
const int perms,
bool silent )
staticprivate
Returns
true if all the asked permissions are ok
Parameters
paththe path to the file to check
permsbit mask of file_perms
silentoutput not messages if set to true

Definition at line 195 of file Filesystem.cpp.

◆ check_sys_paths()

bool check_sys_paths ( )
staticprivate

returns true if the system path is consistent

Definition at line 396 of file Filesystem.cpp.

◆ check_usr_paths()

bool check_usr_paths ( )
staticprivate

returns true if the user path is consistent

Definition at line 422 of file Filesystem.cpp.

◆ click_file_path()

QString click_file_path ( )
static

Returns a string containing the path to the click.wav file used in the metronome.

  It is a concatenation of #__sys_data_path and
  #CLICK_SAMPLE.

Definition at line 505 of file Filesystem.cpp.

◆ default_song_name()

QString default_song_name ( )
static

Default option to offer the user when saving an empty song to disk.

Definition at line 474 of file Filesystem.cpp.

◆ demos_dir()

QString demos_dir ( )
static

returns system demos path

Definition at line 612 of file Filesystem.cpp.

◆ determineDrumkitType()

Filesystem::DrumkitType determineDrumkitType ( const QString & sPath)
static
Parameters
sPathAbsolute path to the drumkit folder containing a drumkit.xml file.

Definition at line 1032 of file Filesystem.cpp.

◆ dir_exists()

bool dir_exists ( const QString & path,
bool silent = false )
static

returns true if the given path is a regular directory

Parameters
paththe path to the file to check
silentoutput not messages if set to true

Definition at line 263 of file Filesystem.cpp.

◆ dir_readable()

bool dir_readable ( const QString & path,
bool silent = false )
static

returns true if the given path is a readable regular directory

Parameters
paththe path to the file to check
silentoutput not messages if set to true

Definition at line 267 of file Filesystem.cpp.

◆ dir_writable()

bool dir_writable ( const QString & path,
bool silent = false )
static

returns true if the given path is a writable regular directory

Parameters
paththe path to the file to check
silentoutput not messages if set to true

Definition at line 271 of file Filesystem.cpp.

◆ doc_dir()

QString doc_dir ( )
static

returns documentation path

Definition at line 540 of file Filesystem.cpp.

◆ drumkit_backup_path()

QString drumkit_backup_path ( const QString & dk_path)
static

Create a backup path from a drumkit path.

It will contain the current datetime to both make individual backup names unique and to make it more easy to handle them.

Definition at line 871 of file Filesystem.cpp.

◆ drumkit_default_kit()

QString drumkit_default_kit ( )
static

Definition at line 662 of file Filesystem.cpp.

◆ drumkit_dir_search()

QString drumkit_dir_search ( const QString & dk_name,
Lookup lookup )
static

returns the directory holding the named drumkit searching within user then system drumkits

Parameters
dk_namethe drumkit name
lookupWhere to search (system/user folder or both) for the drumkit.

Definition at line 817 of file Filesystem.cpp.

◆ drumkit_exists()

bool drumkit_exists ( const QString & dk_name)
static

returns true if the drumkit exists within usable system or user drumkits

Parameters
dk_namethe drumkit name

Definition at line 738 of file Filesystem.cpp.

◆ drumkit_file()

QString drumkit_file ( const QString & dk_path)
static

returns the path to the xml file within a supposed drumkit path

Parameters
dk_paththe path to the drumkit

Definition at line 862 of file Filesystem.cpp.

◆ drumkit_list()

QStringList drumkit_list ( const QString & path)
staticprivate
Returns
a list of usable drumkits, which means having a readable drumkit.xml file
Parameters
paththe path to search in for drumkits

Definition at line 649 of file Filesystem.cpp.

◆ drumkit_path_search()

QString drumkit_path_search ( const QString & dk_name,
Lookup lookup = Lookup::stacked,
bool bSilent = false )
static

Returns the path to a H2Core::Drumkit folder.

The search will first be performed within user-level drumkits system drumkits using usr_drumkit_list() and usr_drumkits_dir() and later, in case the H2Core::Drumkit could not be found, within the system-level drumkits using sys_drumkit_list() and sys_drumkits_dir().

When under session management (see NsmClient::m_bUnderSessionManagement) the function will first look for a "drumkit" symlink or folder within NsmClient::m_sSessionFolderPath. If it either is not a valid H2Core::Drumkit or the not the one corresponding to dk_name, the user- and system-level drumkits will be searched instead.

Parameters
dk_nameName of the H2Core::Drumkit. In the user-level and system-level lookup it has to correspond to the name of the folder holding the samples and the DRUMKIT_XML file. For the usage of a local H2Core::Drumkit under session management it has to match the second-level "name" node within the DRUMKIT_XML file.
lookupWhere to search (system/user folder or both) for the drumkit.
bSilentwhether the function should trigger log messages. If set to true, the calling function is expected to handle the log messages instead.
Returns
Full path to the folder containing the samples of the H2Core::Drumkit corresponding to dk_name.

Definition at line 747 of file Filesystem.cpp.

◆ drumkit_usr_path()

QString drumkit_usr_path ( const QString & dk_name)
static

returns path for a drumkit within user drumkit path

Parameters
dk_namethe drumkit name

Definition at line 743 of file Filesystem.cpp.

◆ drumkit_valid()

bool drumkit_valid ( const QString & dk_path)
static

returns true if the path contains a usable drumkit

Parameters
dk_paththe root drumkit location

Definition at line 833 of file Filesystem.cpp.

◆ drumkit_xml()

QString drumkit_xml ( )
static

Returns filename and extension of the expected drumkit file.

Definition at line 867 of file Filesystem.cpp.

◆ drumkit_xsd()

QString drumkit_xsd ( )
static

returns the drumkit XSD (xml schema definition) name

Definition at line 514 of file Filesystem.cpp.

◆ drumkit_xsd_legacy_paths()

QStringList drumkit_xsd_legacy_paths ( )
static
Returns
List of absolute paths to all formerly used drumkit.xsd files.

Definition at line 1049 of file Filesystem.cpp.

◆ drumkit_xsd_path()

QString drumkit_xsd_path ( )
static

returns the path to the drumkit XSD (xml schema definition) file

Definition at line 518 of file Filesystem.cpp.

◆ empty_sample_path()

QString empty_sample_path ( )
static

returns system empty sample file path

Definition at line 469 of file Filesystem.cpp.

◆ empty_song_path()

QString empty_song_path ( )
static

Provides the full path to the current empty song.

The basename consists of a fixed expression and an optional suffix ensuring the path does not point to an existing file.

Empty songs are handled in Hydrogen as follows: Upon creation, the empty song will be assigned a Song::m_sFilename identical to the return value of this function. This triggers autosave files to be generated corresponding to empty song path. If the user attempts to save the song from within the GUI, she will be prompted a "Save As" dialog and is asked to provide a new name. This way a file using the empty song path does normally not exists. But since the return value of this function is reproducible, Hydrogen is able to recover unsaved modifications applied to an empty song. If the user - by design or coincidence - picks the empty song path to save a file or if the OSC API is used to save the empty song, empty_song_path() will use a suffix to return yet again a path to a non-existing file and allow for the behavior described above.

Definition at line 478 of file Filesystem.cpp.

◆ ensure_session_compatibility()

QString ensure_session_compatibility ( const QString & sPath)
static

If Hydrogen is under session management, we support for paths relative to the session folder.

This is required to allow for sessions being renamed or duplicated.

Definition at line 1013 of file Filesystem.cpp.

◆ file_copy()

bool file_copy ( const QString & src,
const QString & dst,
bool overwrite = false,
bool bSilent = false )
static

copy a source file to a destination

Parameters
srcsource file path
dstdestination file path
overwriteallow to overwrite an existing file if set to true
bSilentWhether debug and info messages should be logged.

Definition at line 316 of file Filesystem.cpp.

◆ file_executable()

bool file_executable ( const QString & path,
bool silent = false )
static

returns true if the given path is an existing executable regular file

Parameters
paththe path to the file to check
silentoutput not messages if set to true

Definition at line 259 of file Filesystem.cpp.

◆ file_exists()

bool file_exists ( const QString & path,
bool silent = false )
static

returns true if the given path is an existing regular file

Parameters
paththe path to the file to check
silentoutput not messages if set to true

Definition at line 247 of file Filesystem.cpp.

◆ file_is_under_drumkit()

bool file_is_under_drumkit ( const QString & fname)
static

Checks if the given filepath is under an existing user or system drumkit path, not the existence of the file.

Definition at line 707 of file Filesystem.cpp.

◆ file_readable()

bool file_readable ( const QString & path,
bool silent = false )
static

returns true if the given path is an existing readable regular file

Parameters
paththe path to the file to check
silentoutput not messages if set to true

Definition at line 251 of file Filesystem.cpp.

◆ file_writable()

bool file_writable ( const QString & path,
bool silent = false )
static

returns true if the given path is a possibly writable file (may exist or not)

Parameters
paththe path to the file to check
silentoutput not messages if set to true

Definition at line 255 of file Filesystem.cpp.

◆ get_basename_idx_under_drumkit()

int get_basename_idx_under_drumkit ( const QString & fname)
static

Returns the index of the basename if the given path is under an existing user or system drumkit path, otherwise -1.

Definition at line 712 of file Filesystem.cpp.

◆ getPreferencesOverwritePath()

const QString & getPreferencesOverwritePath ( )
inlinestatic
Returns
m_sPreferencesOverwritePath

Definition at line 540 of file Filesystem.h.

◆ i18n_dir()

QString i18n_dir ( )
static

returns internationalization path

Definition at line 544 of file Filesystem.cpp.

◆ img_dir()

QString img_dir ( )
static

returns gui image path

Definition at line 536 of file Filesystem.cpp.

◆ info()

void info ( )
static

send current settings information to logger with INFO severity

Definition at line 971 of file Filesystem.cpp.

◆ isSongPathValid()

bool isSongPathValid ( const QString & sSongPath,
bool bCheckExistance = false )
static

Checks the path pointing to a .h2song.

It will be checked whether songPath

  • is absolute
  • exists (if bCheckExistance is set to true)
  • has the '.h2song' suffix
  • is writable (read-only songs are considered valid as well and the function returns true. But it also triggers an event informing the GUI to show a read-only warning.)
Parameters
sSongPathAbsolute path to an .h2song file.
bCheckExistanceWhether the existence of the file is checked (should be true for opening and false for creating a new song)
Returns
true - if valid.

Definition at line 914 of file Filesystem.cpp.

◆ ladspa_paths()

QStringList ladspa_paths ( )
static

returns user ladspa paths

Definition at line 455 of file Filesystem.cpp.

◆ log_file_path()

QString log_file_path ( )
static

returns the full path (including filename) of the logfile

Definition at line 530 of file Filesystem.cpp.

◆ mkdir()

bool mkdir ( const QString & path)
static

create a path

Parameters
paththe path to the directory to be created

Definition at line 276 of file Filesystem.cpp.

◆ path_usable()

bool path_usable ( const QString & path,
bool create = true,
bool silent = false )
static

returns true if the path is a readable and writable regular directory, create if it not exists

Parameters
paththe path to the file to check
createwill try to create path if not exists and set to true
silentoutput not messages if set to true

Definition at line 285 of file Filesystem.cpp.

◆ pattern_drumkits()

QStringList pattern_drumkits ( )
static

returns a list of existing drumkit sub dir into the patterns directory

Definition at line 877 of file Filesystem.cpp.

◆ pattern_list() [1/2]

QStringList pattern_list ( )
static

returns a list of existing patterns

Definition at line 882 of file Filesystem.cpp.

◆ pattern_list() [2/2]

QStringList pattern_list ( const QString & path)
static

returns a list of existing patterns

Parameters
paththe path to look for patterns in

Definition at line 887 of file Filesystem.cpp.

◆ pattern_path()

QString pattern_path ( const QString & dk_name,
const QString & p_name )
static

returns user patterns path, add file extension

Definition at line 576 of file Filesystem.cpp.

◆ pattern_xsd_path()

QString pattern_xsd_path ( )
static

returns the path to the pattern XSD (xml schema definition) file

Definition at line 522 of file Filesystem.cpp.

◆ patterns_dir() [1/2]

QString patterns_dir ( )
static

returns user patterns path

Definition at line 568 of file Filesystem.cpp.

◆ patterns_dir() [2/2]

QString patterns_dir ( const QString & dk_name)
static

returns user patterns path for a specific drumkit

Definition at line 572 of file Filesystem.cpp.

◆ playlist_list()

QStringList playlist_list ( )
static

returns a list of existing playlists

Definition at line 966 of file Filesystem.cpp.

◆ playlist_path()

QString playlist_path ( const QString & pl_name)
static

returns user playlist path, add file extension

Definition at line 600 of file Filesystem.cpp.

◆ playlist_xsd_path()

QString playlist_xsd_path ( )
static

returns the path to the playlist pattern XSD (xml schema definition) file

Definition at line 526 of file Filesystem.cpp.

◆ playlists_dir()

QString playlists_dir ( )
static

returns user playlist path

Definition at line 596 of file Filesystem.cpp.

◆ plugins_dir()

QString plugins_dir ( )
static

returns user plugins path

Definition at line 584 of file Filesystem.cpp.

◆ prepare_sample_path()

QString prepare_sample_path ( const QString & fname)
static

Returns the basename if the given path is under an existing user or system drumkit path, otherwise the given fname.

Definition at line 698 of file Filesystem.cpp.

◆ repositories_cache_dir()

QString repositories_cache_dir ( )
static

returns user repository cache path

Definition at line 608 of file Filesystem.cpp.

◆ rerouteDrumkitPath()

QString rerouteDrumkitPath ( const QString & sDrumkitPath)
static

Reroutes stored drumkit paths pointing to a temporary AppImage system data folder to the current AppImage one.

Since AppImages are mounted at a random point each time they are started the absolute path of their system data folder changes every time. To nevertheless support using system drumkits consistently, we try to determine whether the stored kit is a system one and tweak its path. (Without replacing the random part of the path the lookup would fall back to a name-based one which always checks user-level kits first. Having a GMRockKit in ~/.hydrogen/data/drumkits too, would make the system's one inaccessible).

Parameters
sDrumkitPathAbsolute path that need rerouting.

Definition at line 1068 of file Filesystem.cpp.

◆ rm()

bool rm ( const QString & path,
bool recursive = false,
bool bSilent = false )
static

remove a path

Parameters
paththe path to be removed
recursiveperform recursive removal if set to true
bSilentWhether debug and info messages should be logged.

Definition at line 343 of file Filesystem.cpp.

◆ rm_fr()

bool rm_fr ( const QString & path,
bool bSilent = false )
staticprivate

recursively remove a path

Definition at line 368 of file Filesystem.cpp.

◆ scripts_dir()

QString scripts_dir ( )
static

returns user scripts path

Definition at line 548 of file Filesystem.cpp.

◆ setPreferencesOverwritePath()

void setPreferencesOverwritePath ( const QString & sPath)
inlinestatic
Parameters
sPathSets m_sPreferencesOverwritePath

Definition at line 543 of file Filesystem.h.

◆ song_exists()

bool song_exists ( const QString & sg_name)
static

returns true if the song file exists

Parameters
sg_namethe song name

Definition at line 909 of file Filesystem.cpp.

◆ song_list()

QStringList song_list ( )
static

returns a list of existing songs

Definition at line 893 of file Filesystem.cpp.

◆ song_list_cleared()

QStringList song_list_cleared ( )
static

returns a list of existing songs, excluding the autosaved one

Definition at line 898 of file Filesystem.cpp.

◆ song_path()

QString song_path ( const QString & sg_name)
static

returns user song path, add file extension

Definition at line 564 of file Filesystem.cpp.

◆ songs_dir()

QString songs_dir ( )
static

returns user songs path

Definition at line 552 of file Filesystem.cpp.

◆ sys_config_path()

QString sys_config_path ( )
static

returns system config path

Definition at line 461 of file Filesystem.cpp.

◆ sys_data_path()

QString sys_data_path ( )
static

returns system data path

Definition at line 446 of file Filesystem.cpp.

◆ sys_drumkit_list()

QStringList sys_drumkit_list ( )
static

returns list of usable system drumkits ( see Filesystem::drumkit_list )

Definition at line 689 of file Filesystem.cpp.

◆ sys_drumkits_dir()

QString sys_drumkits_dir ( )
static

returns system drumkits path

Definition at line 588 of file Filesystem.cpp.

◆ sys_theme_dir()

QString sys_theme_dir ( )
static

Definition at line 560 of file Filesystem.cpp.

◆ theme_list()

QStringList theme_list ( )
static

Definition at line 959 of file Filesystem.cpp.

◆ tmp_dir()

QString tmp_dir ( )
static

returns temp path

Definition at line 624 of file Filesystem.cpp.

◆ tmp_file_path()

QString tmp_file_path ( const QString & base)
static

touch a temporary file under tmp_dir() and return it's path.

if base has a suffix it will be preserved, spaces will be replaced by underscores.

Parameters
basepart of the path

Definition at line 628 of file Filesystem.cpp.

◆ untitled_playlist_file_name()

QString untitled_playlist_file_name ( )
static

returns untitled playlist file name

Definition at line 501 of file Filesystem.cpp.

◆ untitled_song_name()

QString untitled_song_name ( )
static

returns untitled song name

Definition at line 497 of file Filesystem.cpp.

◆ usr_click_file_path()

QString usr_click_file_path ( )
static

returns click file path from user directory if exists, otherwise from system

Definition at line 509 of file Filesystem.cpp.

◆ usr_config_path()

QString usr_config_path ( )
static

returns user config path

Definition at line 465 of file Filesystem.cpp.

◆ usr_data_path()

QString usr_data_path ( )
static

returns user data path

Definition at line 450 of file Filesystem.cpp.

◆ usr_drumkit_list()

QStringList usr_drumkit_list ( )
static

returns list of usable user drumkits ( see Filesystem::drumkit_list )

Definition at line 693 of file Filesystem.cpp.

◆ usr_drumkits_dir()

QString usr_drumkits_dir ( )
static

returns user drumkits path

Definition at line 592 of file Filesystem.cpp.

◆ usr_theme_dir()

QString usr_theme_dir ( )
static

Definition at line 556 of file Filesystem.cpp.

◆ validateFilePath()

QString validateFilePath ( const QString & sPath)
static

Takes an arbitrary path, replaces white spaces by underscores and removes all characters apart from latin characters, arabic numbers, underscores and dashes.

Definition at line 949 of file Filesystem.cpp.

◆ write_to_file()

bool write_to_file ( const QString & dst,
const QString & content )
static

writes to a file

Parameters
dstthe destination path
contentthen string to write

Definition at line 299 of file Filesystem.cpp.

◆ xsd_dir()

QString xsd_dir ( )
static

returns system xsd path

Definition at line 616 of file Filesystem.cpp.

◆ xsd_legacy_dir()

QString xsd_legacy_dir ( )
static

Definition at line 620 of file Filesystem.cpp.

Field Documentation

◆ __ladspa_paths

QStringList __ladspa_paths
staticprivate

paths to laspa plugins

Definition at line 537 of file Filesystem.h.

◆ __logger

Logger * __logger = nullptr
staticprivate

a pointer to the logger

Definition at line 488 of file Filesystem.h.

◆ __sys_data_path

QString __sys_data_path
staticprivate

Path to the system files set in Filesystem::bootstrap().

If Q_OSMACX is set, it will be a concatenation of QCoreApplication::applicationDirPath() and "/../Resources/data/" (H2CORE_HAVE_BUNDLE defined) or "/data/" (else). If, instead, WIN32 is set, it is a concatenation of QCoreApplication::applicationDirPath() and "/data/". In case the application is neither run on Mac or Windows, it is set to a concatenation of H2_SYS_PATH and "/data/".

If Filesystem::bootstrap() was called with the sys_path argument preset, it will overwrite all the choices above.

Finally, if the variable doesn't point to a readable directory afterwards, it is set to a concatenation of QCoreApplication::applicationDirPath(), "/", and LOCAL_DATA_PATH. the path to the system files

Definition at line 533 of file Filesystem.h.

◆ __usr_cfg_path

QString __usr_cfg_path
staticprivate

the path to the user config file

Definition at line 535 of file Filesystem.h.

◆ __usr_data_path

QString __usr_data_path
staticprivate

the path to the user files

Definition at line 534 of file Filesystem.h.

◆ __usr_log_path

QString __usr_log_path = QDir::homePath().append( "/" H2_USR_PATH "/" LOG_FILE)
staticprivate

the path to the log file

Definition at line 536 of file Filesystem.h.

◆ drumkit_ext

const QString drumkit_ext = ".h2drumkit"
static

Definition at line 91 of file Filesystem.h.

◆ m_sPreferencesOverwritePath

QString m_sPreferencesOverwritePath = ""
staticprivate

If this variable is non-empty, its content will be used as an alternative to store and load the preferences.

Definition at line 496 of file Filesystem.h.

◆ patterns_ext

const QString patterns_ext = ".h2pattern"
static

Definition at line 89 of file Filesystem.h.

◆ patterns_filter_name

const QString patterns_filter_name = "Hydrogen Patterns (*.h2pattern)"
static

Definition at line 96 of file Filesystem.h.

◆ playlist_ext

const QString playlist_ext = ".h2playlist"
static

Definition at line 90 of file Filesystem.h.

◆ playlists_filter_name

const QString playlists_filter_name = "Hydrogen Playlists (*.h2playlist)"
static

Definition at line 97 of file Filesystem.h.

◆ scripts_ext

const QString scripts_ext = ".sh"
static

Definition at line 88 of file Filesystem.h.

◆ scripts_filter_name

const QString scripts_filter_name = "Hydrogen Scripts (*.sh)"
static

Definition at line 95 of file Filesystem.h.

◆ songs_ext

const QString songs_ext = ".h2song"
static

Definition at line 87 of file Filesystem.h.

◆ songs_filter_name

const QString songs_filter_name = "Hydrogen Songs (*.h2song)"
static

Definition at line 93 of file Filesystem.h.

◆ themes_ext

const QString themes_ext = ".h2theme"
static

Definition at line 92 of file Filesystem.h.

◆ themes_filter_name

const QString themes_filter_name = "Hydrogen Theme (*.h2theme)"
static

Definition at line 94 of file Filesystem.h.