Chris@679: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@679: Chris@679: /* Chris@679: Sonic Visualiser Chris@679: An audio file viewer and annotation editor. Chris@679: Centre for Digital Music, Queen Mary, University of London. Chris@679: Chris@679: This program is free software; you can redistribute it and/or Chris@679: modify it under the terms of the GNU General Public License as Chris@679: published by the Free Software Foundation; either version 2 of the Chris@679: License, or (at your option) any later version. See the file Chris@679: COPYING included with this distribution for more information. Chris@679: */ Chris@679: Chris@679: /* Chris@679: This is a modified version of a source file from the Chris@679: Rosegarden MIDI and audio sequencer and notation editor. Chris@679: This file copyright 2005-2011 Chris Cannam and the Rosegarden Chris@679: development team. Chris@679: */ Chris@679: Chris@679: #ifndef _RESOURCE_FINDER_H_ Chris@679: #define _RESOURCE_FINDER_H_ Chris@679: Chris@679: #include Chris@686: Chris@686: #include "Debug.h" Chris@679: Chris@679: class ResourceFinder Chris@679: { Chris@679: public: Chris@679: ResourceFinder() { } Chris@679: virtual ~ResourceFinder() { } Chris@679: Chris@679: /** Chris@679: * Return the location (as a true file path, or a Qt4 ":"-prefixed Chris@679: * resource path) of the file best matching the given resource Chris@679: * filename in the given resource category. Chris@679: * Chris@679: * Category should be a relative directory path without leading or Chris@679: * trailing slashes, for example "chords". The fileName is the Chris@679: * remainder of the file name without any path content, for Chris@679: * example "user_chords.xml". Chris@679: * Chris@679: * Returns an empty string if no matching resource is found. Chris@679: * Chris@679: * Use this when you know that a particular resource is required Chris@679: * and just need to locate it. Chris@679: */ Chris@679: QString getResourcePath(QString resourceCat, QString fileName); Chris@679: Chris@679: /** Chris@679: * Return a list of full file paths for files with the given file Chris@679: * extension, found in the given resource category. Chris@679: * Chris@679: * Category should be a relative directory path without leading or Chris@679: * trailing slashes, for example "chords". File extension should Chris@679: * be the extension without the dot, for example "xml". Returned Chris@679: * list may mix true file paths in both installed and user Chris@679: * locations with Qt4 ":"-prefixed resource paths. Chris@679: * Chris@679: * Use this when you need to enumerate the options available for Chris@679: * use directly in the program (rather than e.g. offering the user Chris@679: * a file-open dialog). Chris@679: */ Chris@679: QStringList getResourceFiles(QString resourceCat, QString fileExt); Chris@679: Chris@679: /** Chris@679: * Return the true file path for installed resource files in the Chris@679: * given resource category. Category should be a relative Chris@679: * directory path without leading or trailing slashes, for example Chris@679: * "chords". Note that resources may also exist in the Qt4 Chris@679: * resource bundle; this method only returns the external Chris@679: * (installed) resource location. Use getResourceFiles instead to Chris@679: * return an authoritative list of available resources of a given Chris@679: * type. Chris@679: * Chris@679: * Use this when you need a file path, e.g. for use in a file Chris@679: * finder dialog. Chris@679: */ Chris@679: QString getResourceDir(QString resourceCat); Chris@679: Chris@679: /** Chris@679: * Return the true file path for the location in which the named Chris@679: * resource file in the given resource category should be saved. Chris@681: * ResourceFinder will make a best effort to ensure this directory Chris@681: * actually exists, before returning. Chris@679: */ Chris@679: QString getResourceSavePath(QString resourceCat, QString fileName); Chris@679: Chris@679: /** Chris@679: * Return the true file path for the location in which resource Chris@679: * files in the given resource category should be saved. Chris@679: */ Chris@679: QString getResourceSaveDir(QString resourceCat); Chris@679: Chris@679: /** Chris@679: * If the named resource file in the given resource category is Chris@679: * available only as a bundled resource, copy it out into the user Chris@679: * location returned by getResourceSavePath so that it can be read Chris@679: * by non-Qt code. Any subsequent call to getResourcePath for Chris@679: * this resource should return a true file path (if the resource Chris@679: * exists) in either user or system location, or an empty string Chris@679: * (if the resource does not exist), but never a ":"-prefixed Chris@679: * resource path. This function does not overwrite any existing Chris@679: * unbundled copy of the resource. Chris@679: * Chris@679: * Return false if a system error occurs during unbundling Chris@679: * (e.g. disk full). Chris@679: */ Chris@679: bool unbundleResource(QString resourceCat, QString fileName); Chris@679: Chris@680: /** Chris@680: * Return the root path for user-specific resource installation Chris@680: * for this application (i.e. resources beneath the user's home Chris@680: * directory). Chris@680: */ Chris@679: QString getUserResourcePrefix(); Chris@680: Chris@680: /** Chris@680: * Return the root paths for systemwide resource installations for Chris@680: * this application. Chris@680: */ Chris@679: QStringList getSystemResourcePrefixList(); Chris@680: Chris@680: /** Chris@680: * Return all root paths for resource installations for this Chris@680: * application, in the order in which they will be searched. This Chris@680: * list consists of the user-specific path Chris@680: * (getUserResourcePrefix()) followed by the systemwide paths Chris@680: * (getSystemResourcePrefixList()). Chris@680: */ Chris@679: QStringList getResourcePrefixList(); Chris@679: }; Chris@679: Chris@679: #endif Chris@679: Chris@679: