|
hydrogen 1.1.1
|
Filesystem is a thin layer over QDir, QFile and QFileInfo. More...
#include <Filesystem.h>
Public Types | |
| 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 bool | bootstrap (Logger *logger, const QString &sys_path=nullptr) |
| check user and system filesystem usability More... | |
| static QString | sys_data_path () |
| returns system data path More... | |
| static QString | usr_data_path () |
| returns user data path More... | |
| static QStringList | ladspa_paths () |
| returns user ladspa paths More... | |
| static QString | sys_config_path () |
| returns system config path More... | |
| static QString | usr_config_path () |
| returns user config path More... | |
| static QString | empty_sample_path () |
| returns system empty sample file path More... | |
| static QString | empty_song_path () |
| returns system empty song file path More... | |
| static QString | untitled_song_file_name () |
| returns untitled song file name More... | |
| static QString | click_file_path () |
| Returns a string containing the path to the click.wav file used in the metronome. More... | |
| static QString | usr_click_file_path () |
| returns click file path from user directory if exists, otherwise from system More... | |
| static QString | drumkit_xsd_path () |
| returns the path to the drumkit XSD (xml schema definition) file More... | |
| static QString | pattern_xsd_path () |
| returns the path to the pattern XSD (xml schema definition) file More... | |
| static QString | playlist_xsd_path () |
| returns the path to the playlist pattern XSD (xml schema definition) file More... | |
| static QString | log_file_path () |
| returns the full path (including filename) of the logfile More... | |
| static QString | img_dir () |
| returns gui image path More... | |
| static QString | doc_dir () |
| returns documentation path More... | |
| static QString | i18n_dir () |
| returns internationalization path More... | |
| static QString | scripts_dir () |
| returns user scripts path More... | |
| static QString | songs_dir () |
| returns user songs path More... | |
| static QString | song_path (const QString &sg_name) |
| returns user song path, add file extension More... | |
| static QString | patterns_dir () |
| returns user patterns path More... | |
| static QString | patterns_dir (const QString &dk_name) |
| returns user patterns path for a specific drumkit More... | |
| static QString | pattern_path (const QString &dk_name, const QString &p_name) |
| returns user patterns path, add file extension More... | |
| static QString | plugins_dir () |
| returns user plugins path More... | |
| static QString | sys_drumkits_dir () |
| returns system drumkits path More... | |
| static QString | usr_drumkits_dir () |
| returns user drumkits path More... | |
| static QString | playlists_dir () |
| returns user playlist path More... | |
| static QString | playlist_path (const QString &pl_name) |
| returns user playlist path, add file extension More... | |
| static QString | untitled_playlist_file_name () |
| returns untitled playlist file name More... | |
| static QString | cache_dir () |
| returns user cache path More... | |
| static QString | repositories_cache_dir () |
| returns user repository cache path More... | |
| static QString | demos_dir () |
| returns system demos path More... | |
| static QString | xsd_dir () |
| returns system xsd path More... | |
| static QString | tmp_dir () |
| returns temp path More... | |
| static QString | tmp_file_path (const QString &base) |
| touch a temporary file under tmp_dir() and return it's path. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| static QStringList | sys_drumkit_list () |
| returns list of usable system drumkits ( see Filesystem::drumkit_list ) More... | |
| static QStringList | usr_drumkit_list () |
| returns list of usable user drumkits ( see Filesystem::drumkit_list ) More... | |
| static bool | drumkit_exists (const QString &dk_name) |
| returns true if the drumkit exists within usable system or user drumkits More... | |
| static QString | drumkit_usr_path (const QString &dk_name) |
| returns path for a drumkit within user drumkit path More... | |
| static QString | drumkit_path_search (const QString &dk_name, Lookup lookup=Lookup::stacked, bool bSilent=false) |
| Returns the path to a H2Core::Drumkit folder. More... | |
| static QString | drumkit_dir_search (const QString &dk_name, Lookup lookup) |
| returns the directory holding the named drumkit searching within user then system drumkits More... | |
| static bool | drumkit_valid (const QString &dk_path) |
| returns true if the path contains a usable drumkit More... | |
| static QString | drumkit_file (const QString &dk_path) |
| returns the path to the xml file within a supposed drumkit path More... | |
| static QStringList | pattern_drumkits () |
| returns a list of existing drumkit sub dir into the patterns directory More... | |
| static QStringList | pattern_list () |
| returns a list of existing patterns More... | |
| static QStringList | pattern_list (const QString &path) |
| returns a list of existing patterns More... | |
| static QStringList | song_list () |
| returns a list of existing songs More... | |
| static QStringList | song_list_cleared () |
| returns a list of existing songs, excluding the autosaved one More... | |
| static bool | song_exists (const QString &sg_name) |
| returns true if the song file exists More... | |
| static void | info () |
| send current settings information to logger with INFO severity More... | |
| static QStringList | playlist_list () |
| returns a list of existing playlists More... | |
| static bool | file_exists (const QString &path, bool silent=false) |
| returns true if the given path is an existing regular file More... | |
| static bool | file_readable (const QString &path, bool silent=false) |
| returns true if the given path is an existing readable regular file More... | |
| 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) More... | |
| static bool | file_executable (const QString &path, bool silent=false) |
| returns true if the given path is an existing executable regular file More... | |
| static bool | dir_readable (const QString &path, bool silent=false) |
| returns true if the given path is a readable regular directory More... | |
| static bool | dir_writable (const QString &path, bool silent=false) |
| returns true if the given path is a writable regular directory More... | |
| 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 More... | |
| static bool | write_to_file (const QString &dst, const QString &content) |
| writes to a file More... | |
| static bool | file_copy (const QString &src, const QString &dst, bool overwrite=false) |
| copy a source file to a destination More... | |
| static bool | rm (const QString &path, bool recursive=false) |
| remove a path More... | |
| static bool | mkdir (const QString &path) |
| create a path More... | |
| static const QString & | getPreferencesOverwritePath () |
| static void | setPreferencesOverwritePath (const QString &sPath) |
Static Public Member Functions inherited from Object | |
| static void | set_count (bool flag) |
| enable/disable class instances counting More... | |
| static bool | count_active () |
| return true if class instances counting is enabled More... | |
| static unsigned | objects_count () |
| return the number of objects More... | |
| static void | write_objects_map_to (std::ostream &out) |
| output the full objects map to a given ostream More... | |
| static void | write_objects_map_to_cerr () |
| output objects map to stderr More... | |
| static int | bootstrap (Logger *logger, bool count=false) |
| must be called before any Object instantiation ! More... | |
| static Logger * | logger () |
| return the logger instance More... | |
Static Public Attributes | |
| static const QString | songs_ext = ".h2song" |
| static const QString | scripts_ext = ".sh" |
| static const QString | patterns_ext = ".h2pattern" |
| static const QString | playlist_ext = ".h2playlist" |
| static const QString | drumkit_ext = ".h2drumkit" |
| static const QString | songs_filter_name = "Hydrogen Songs (*.h2song)" |
| static const QString | scripts_filter_name = "Hydrogen Scripts (*.sh)" |
| static const QString | patterns_filter_name = "Hydrogen Patterns (*.h2pattern)" |
| static const QString | playlists_filter_name = "Hydrogen Playlists (*.h2playlist)" |
Static Public Attributes inherited from Object | |
| static QString | sPrintIndention = " " |
| String used to format the debugging string output of some core classes. More... | |
Static Private Member Functions | |
| static bool | check_sys_paths () |
| returns true if the system path is consistent More... | |
| static bool | check_usr_paths () |
| returns true if the user path is consistent More... | |
| static bool | rm_fr (const QString &path) |
| recursively remove a path More... | |
| static QStringList | drumkit_list (const QString &path) |
| static bool | check_permissions (const QString &path, const int perms, bool silent) |
Static Private Attributes | |
| static Logger * | __logger = nullptr |
| a pointer to the logger More... | |
| static QString | m_sPreferencesOverwritePath = "" |
| If this variable is non-empty, its content will be used as an alternative to store and load the preferences. More... | |
| static QString | __sys_data_path |
| Path to the system files set in Filesystem::bootstrap(). More... | |
| static QString | __usr_data_path |
| the path to the user files More... | |
| static QString | __usr_cfg_path |
| the path to the user config file More... | |
| static QString | __usr_log_path = QDir::homePath().append( "/" H2_USR_PATH "/" LOG_FILE) |
| the path to the log file More... | |
| static QStringList | __ladspa_paths |
| paths to laspa plugins More... | |
Additional Inherited Members | |
Public Member Functions inherited from Object | |
| ~Object () | |
| destructor More... | |
| Object (const Object &obj) | |
| copy constructor More... | |
| Object (const char *class_name) | |
| constructor More... | |
| const char * | class_name () const |
| return the class name More... | |
| virtual QString | toQString (const QString &sPrefix, bool bShort=true) const |
| Formatted string version for debugging purposes. More... | |
| void | Print (bool bShort=true) const |
| Prints content of toQString() via DEBUGLOG. More... | |
Static Protected Attributes inherited from Object | |
| static Logger * | __logger = nullptr |
| logger instance pointer More... | |
Filesystem is a thin layer over QDir, QFile and QFileInfo.
| enum file_perms |
flags available for check_permissions()
| Enumerator | |
|---|---|
| is_dir | |
| is_file | |
| is_readable | |
| is_writable | |
| is_executable | |
|
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. |
|
static |
check user and system filesystem usability
| logger | is a pointer to the logger instance which will be used |
| sys_path | an alternate system data path |
|
static |
returns user cache path
|
staticprivate |
| path | the path to the file to check |
| perms | bit mask of file_perms |
| silent | output not messages if set to true |
|
staticprivate |
returns true if the system path is consistent
|
staticprivate |
returns true if the user path is consistent
|
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.
|
static |
returns system demos path
|
static |
returns true if the given path is a readable regular directory
| path | the path to the file to check |
| silent | output not messages if set to true |
|
static |
returns true if the given path is a writable regular directory
| path | the path to the file to check |
| silent | output not messages if set to true |
|
static |
returns documentation path
|
static |
returns the directory holding the named drumkit searching within user then system drumkits
| dk_name | the drumkit name |
| lookup | Where to search (system/user folder or both) for the drumkit. |
|
static |
returns true if the drumkit exists within usable system or user drumkits
| dk_name | the drumkit name |
|
static |
returns the path to the xml file within a supposed drumkit path
| dk_path | the path to the drumkit |
|
staticprivate |
| path | the path to search in for drumkits |
|
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.
| dk_name | Name 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. |
| lookup | Where to search (system/user folder or both) for the drumkit. |
| bSilent | whether the function should trigger log messages. If set to true, the calling function is expected to handle the log messages instead. |
|
static |
returns path for a drumkit within user drumkit path
| dk_name | the drumkit name |
|
static |
returns true if the path contains a usable drumkit
| dk_path | the root drumkit location |
|
static |
returns the path to the drumkit XSD (xml schema definition) file
|
static |
returns system empty sample file path
|
static |
returns system empty song file path
|
static |
copy a source file to a destination
| src | source file path |
| dst | destination file path |
| overwrite | allow to overwrite an existing file if set to true |
|
static |
returns true if the given path is an existing executable regular file
| path | the path to the file to check |
| silent | output not messages if set to true |
|
static |
returns true if the given path is an existing regular file
| path | the path to the file to check |
| silent | output not messages if set to true |
|
static |
Checks if the given filepath is under an existing user or system drumkit path, not the existence of the file.
|
static |
returns true if the given path is an existing readable regular file
| path | the path to the file to check |
| silent | output not messages if set to true |
|
static |
returns true if the given path is a possibly writable file (may exist or not)
| path | the path to the file to check |
| silent | output not messages if set to true |
|
static |
Returns the index of the basename if the given path is under an existing user or system drumkit path, otherwise -1.
|
inlinestatic |
|
static |
returns internationalization path
|
static |
returns gui image path
|
static |
send current settings information to logger with INFO severity
|
static |
returns user ladspa paths
|
static |
returns the full path (including filename) of the logfile
|
static |
create a path
| path | the path to the directory to be created |
|
static |
returns true if the path is a readable and writable regular directory, create if it not exists
| path | the path to the file to check |
| create | will try to create path if not exists and set to true |
| silent | output not messages if set to true |
|
static |
returns a list of existing drumkit sub dir into the patterns directory
|
static |
returns a list of existing patterns
|
static |
returns a list of existing patterns
| path | the path to look for patterns in |
|
static |
returns user patterns path, add file extension
|
static |
returns the path to the pattern XSD (xml schema definition) file
|
static |
returns user patterns path
|
static |
returns user patterns path for a specific drumkit
|
static |
returns a list of existing playlists
|
static |
returns user playlist path, add file extension
|
static |
returns the path to the playlist pattern XSD (xml schema definition) file
|
static |
returns user playlist path
|
static |
returns user plugins path
|
static |
Returns the basename if the given path is under an existing user or system drumkit path, otherwise the given fname.
|
static |
returns user repository cache path
|
static |
remove a path
| path | the path to be removed |
| recursive | perform recursive removal if set to true |
|
staticprivate |
recursively remove a path
|
static |
returns user scripts path
|
inlinestatic |
| sPath | Sets m_sPreferencesOverwritePath |
|
static |
returns true if the song file exists
| sg_name | the song name |
|
static |
returns a list of existing songs
|
static |
returns a list of existing songs, excluding the autosaved one
|
static |
returns user song path, add file extension
|
static |
returns user songs path
|
static |
returns system config path
|
static |
returns system data path
|
static |
returns list of usable system drumkits ( see Filesystem::drumkit_list )
|
static |
returns system drumkits path
|
static |
returns temp path
|
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.
| base | part of the path |
|
static |
returns untitled playlist file name
|
static |
returns untitled song file name
|
static |
returns click file path from user directory if exists, otherwise from system
|
static |
returns user config path
|
static |
returns user data path
|
static |
returns list of usable user drumkits ( see Filesystem::drumkit_list )
|
static |
returns user drumkits path
|
static |
writes to a file
| dst | the destination path |
| content | then string to write |
|
static |
returns system xsd path
|
staticprivate |
paths to laspa plugins
|
staticprivate |
a pointer to the logger
|
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
|
staticprivate |
the path to the user config file
|
staticprivate |
the path to the user files
|
staticprivate |
the path to the log file
|
static |
|
staticprivate |
If this variable is non-empty, its content will be used as an alternative to store and load the preferences.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |