annotate base/ResourceFinder.h @ 1385:b061b9f8fca5

Debug notes, tidying
author Chris Cannam
date Thu, 23 Feb 2017 09:22:56 +0000
parents b4a8d8221eaf
children 48e9f538e6e9
rev   line source
Chris@679 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@679 2
Chris@679 3 /*
Chris@679 4 Sonic Visualiser
Chris@679 5 An audio file viewer and annotation editor.
Chris@679 6 Centre for Digital Music, Queen Mary, University of London.
Chris@679 7
Chris@679 8 This program is free software; you can redistribute it and/or
Chris@679 9 modify it under the terms of the GNU General Public License as
Chris@679 10 published by the Free Software Foundation; either version 2 of the
Chris@679 11 License, or (at your option) any later version. See the file
Chris@679 12 COPYING included with this distribution for more information.
Chris@679 13 */
Chris@679 14
Chris@679 15 /*
Chris@679 16 This is a modified version of a source file from the
Chris@679 17 Rosegarden MIDI and audio sequencer and notation editor.
Chris@679 18 This file copyright 2005-2011 Chris Cannam and the Rosegarden
Chris@679 19 development team.
Chris@679 20 */
Chris@679 21
Chris@679 22 #ifndef _RESOURCE_FINDER_H_
Chris@679 23 #define _RESOURCE_FINDER_H_
Chris@679 24
Chris@679 25 #include <QString>
Chris@686 26
Chris@686 27 #include "Debug.h"
Chris@679 28
Chris@679 29 class ResourceFinder
Chris@679 30 {
Chris@679 31 public:
Chris@679 32 ResourceFinder() { }
Chris@679 33 virtual ~ResourceFinder() { }
Chris@679 34
Chris@679 35 /**
Chris@679 36 * Return the location (as a true file path, or a Qt4 ":"-prefixed
Chris@679 37 * resource path) of the file best matching the given resource
Chris@679 38 * filename in the given resource category.
Chris@679 39 *
Chris@679 40 * Category should be a relative directory path without leading or
Chris@679 41 * trailing slashes, for example "chords". The fileName is the
Chris@679 42 * remainder of the file name without any path content, for
Chris@679 43 * example "user_chords.xml".
Chris@679 44 *
Chris@679 45 * Returns an empty string if no matching resource is found.
Chris@679 46 *
Chris@679 47 * Use this when you know that a particular resource is required
Chris@679 48 * and just need to locate it.
Chris@679 49 */
Chris@679 50 QString getResourcePath(QString resourceCat, QString fileName);
Chris@679 51
Chris@679 52 /**
Chris@679 53 * Return a list of full file paths for files with the given file
Chris@679 54 * extension, found in the given resource category.
Chris@679 55 *
Chris@679 56 * Category should be a relative directory path without leading or
Chris@679 57 * trailing slashes, for example "chords". File extension should
Chris@679 58 * be the extension without the dot, for example "xml". Returned
Chris@679 59 * list may mix true file paths in both installed and user
Chris@679 60 * locations with Qt4 ":"-prefixed resource paths.
Chris@679 61 *
Chris@679 62 * Use this when you need to enumerate the options available for
Chris@679 63 * use directly in the program (rather than e.g. offering the user
Chris@679 64 * a file-open dialog).
Chris@679 65 */
Chris@679 66 QStringList getResourceFiles(QString resourceCat, QString fileExt);
Chris@679 67
Chris@679 68 /**
Chris@679 69 * Return the true file path for installed resource files in the
Chris@679 70 * given resource category. Category should be a relative
Chris@679 71 * directory path without leading or trailing slashes, for example
Chris@679 72 * "chords". Note that resources may also exist in the Qt4
Chris@679 73 * resource bundle; this method only returns the external
Chris@679 74 * (installed) resource location. Use getResourceFiles instead to
Chris@679 75 * return an authoritative list of available resources of a given
Chris@679 76 * type.
Chris@679 77 *
Chris@679 78 * Use this when you need a file path, e.g. for use in a file
Chris@679 79 * finder dialog.
Chris@679 80 */
Chris@679 81 QString getResourceDir(QString resourceCat);
Chris@679 82
Chris@679 83 /**
Chris@679 84 * Return the true file path for the location in which the named
Chris@679 85 * resource file in the given resource category should be saved.
Chris@681 86 * ResourceFinder will make a best effort to ensure this directory
Chris@681 87 * actually exists, before returning.
Chris@679 88 */
Chris@679 89 QString getResourceSavePath(QString resourceCat, QString fileName);
Chris@679 90
Chris@679 91 /**
Chris@679 92 * Return the true file path for the location in which resource
Chris@679 93 * files in the given resource category should be saved.
Chris@679 94 */
Chris@679 95 QString getResourceSaveDir(QString resourceCat);
Chris@679 96
Chris@679 97 /**
Chris@679 98 * If the named resource file in the given resource category is
Chris@679 99 * available only as a bundled resource, copy it out into the user
Chris@679 100 * location returned by getResourceSavePath so that it can be read
Chris@679 101 * by non-Qt code. Any subsequent call to getResourcePath for
Chris@679 102 * this resource should return a true file path (if the resource
Chris@679 103 * exists) in either user or system location, or an empty string
Chris@679 104 * (if the resource does not exist), but never a ":"-prefixed
Chris@679 105 * resource path. This function does not overwrite any existing
Chris@679 106 * unbundled copy of the resource.
Chris@679 107 *
Chris@679 108 * Return false if a system error occurs during unbundling
Chris@679 109 * (e.g. disk full).
Chris@679 110 */
Chris@679 111 bool unbundleResource(QString resourceCat, QString fileName);
Chris@679 112
Chris@680 113 /**
Chris@680 114 * Return the root path for user-specific resource installation
Chris@680 115 * for this application (i.e. resources beneath the user's home
Chris@680 116 * directory).
Chris@680 117 */
Chris@679 118 QString getUserResourcePrefix();
Chris@680 119
Chris@680 120 /**
Chris@680 121 * Return the root paths for systemwide resource installations for
Chris@680 122 * this application.
Chris@680 123 */
Chris@679 124 QStringList getSystemResourcePrefixList();
Chris@680 125
Chris@680 126 /**
Chris@680 127 * Return all root paths for resource installations for this
Chris@680 128 * application, in the order in which they will be searched. This
Chris@680 129 * list consists of the user-specific path
Chris@680 130 * (getUserResourcePrefix()) followed by the systemwide paths
Chris@680 131 * (getSystemResourcePrefixList()).
Chris@680 132 */
Chris@679 133 QStringList getResourcePrefixList();
Chris@679 134 };
Chris@679 135
Chris@679 136 #endif
Chris@679 137
Chris@679 138