annotate base/ResourceFinder.h @ 684:bcca512445f3

Provide option for WavFileWriter to write directly to target file, rather than always using a temporary; make use of it in WritableWaveFileModel so we can read from target file without having to close it first
author Chris Cannam
date Wed, 11 May 2011 11:04:35 +0100
parents 6097aacd7ba3
children b4a8d8221eaf
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@679 26
Chris@679 27 class ResourceFinder
Chris@679 28 {
Chris@679 29 public:
Chris@679 30 ResourceFinder() { }
Chris@679 31 virtual ~ResourceFinder() { }
Chris@679 32
Chris@679 33 /**
Chris@679 34 * Return the location (as a true file path, or a Qt4 ":"-prefixed
Chris@679 35 * resource path) of the file best matching the given resource
Chris@679 36 * filename in the given resource category.
Chris@679 37 *
Chris@679 38 * Category should be a relative directory path without leading or
Chris@679 39 * trailing slashes, for example "chords". The fileName is the
Chris@679 40 * remainder of the file name without any path content, for
Chris@679 41 * example "user_chords.xml".
Chris@679 42 *
Chris@679 43 * Returns an empty string if no matching resource is found.
Chris@679 44 *
Chris@679 45 * Use this when you know that a particular resource is required
Chris@679 46 * and just need to locate it.
Chris@679 47 */
Chris@679 48 QString getResourcePath(QString resourceCat, QString fileName);
Chris@679 49
Chris@679 50 /**
Chris@679 51 * Return a list of full file paths for files with the given file
Chris@679 52 * extension, found in the given resource category.
Chris@679 53 *
Chris@679 54 * Category should be a relative directory path without leading or
Chris@679 55 * trailing slashes, for example "chords". File extension should
Chris@679 56 * be the extension without the dot, for example "xml". Returned
Chris@679 57 * list may mix true file paths in both installed and user
Chris@679 58 * locations with Qt4 ":"-prefixed resource paths.
Chris@679 59 *
Chris@679 60 * Use this when you need to enumerate the options available for
Chris@679 61 * use directly in the program (rather than e.g. offering the user
Chris@679 62 * a file-open dialog).
Chris@679 63 */
Chris@679 64 QStringList getResourceFiles(QString resourceCat, QString fileExt);
Chris@679 65
Chris@679 66 /**
Chris@679 67 * Return the true file path for installed resource files in the
Chris@679 68 * given resource category. Category should be a relative
Chris@679 69 * directory path without leading or trailing slashes, for example
Chris@679 70 * "chords". Note that resources may also exist in the Qt4
Chris@679 71 * resource bundle; this method only returns the external
Chris@679 72 * (installed) resource location. Use getResourceFiles instead to
Chris@679 73 * return an authoritative list of available resources of a given
Chris@679 74 * type.
Chris@679 75 *
Chris@679 76 * Use this when you need a file path, e.g. for use in a file
Chris@679 77 * finder dialog.
Chris@679 78 */
Chris@679 79 QString getResourceDir(QString resourceCat);
Chris@679 80
Chris@679 81 /**
Chris@679 82 * Return the true file path for the location in which the named
Chris@679 83 * resource file in the given resource category should be saved.
Chris@681 84 * ResourceFinder will make a best effort to ensure this directory
Chris@681 85 * actually exists, before returning.
Chris@679 86 */
Chris@679 87 QString getResourceSavePath(QString resourceCat, QString fileName);
Chris@679 88
Chris@679 89 /**
Chris@679 90 * Return the true file path for the location in which resource
Chris@679 91 * files in the given resource category should be saved.
Chris@679 92 */
Chris@679 93 QString getResourceSaveDir(QString resourceCat);
Chris@679 94
Chris@679 95 /**
Chris@679 96 * If the named resource file in the given resource category is
Chris@679 97 * available only as a bundled resource, copy it out into the user
Chris@679 98 * location returned by getResourceSavePath so that it can be read
Chris@679 99 * by non-Qt code. Any subsequent call to getResourcePath for
Chris@679 100 * this resource should return a true file path (if the resource
Chris@679 101 * exists) in either user or system location, or an empty string
Chris@679 102 * (if the resource does not exist), but never a ":"-prefixed
Chris@679 103 * resource path. This function does not overwrite any existing
Chris@679 104 * unbundled copy of the resource.
Chris@679 105 *
Chris@679 106 * Return false if a system error occurs during unbundling
Chris@679 107 * (e.g. disk full).
Chris@679 108 */
Chris@679 109 bool unbundleResource(QString resourceCat, QString fileName);
Chris@679 110
Chris@680 111 /**
Chris@680 112 * Return the root path for user-specific resource installation
Chris@680 113 * for this application (i.e. resources beneath the user's home
Chris@680 114 * directory).
Chris@680 115 */
Chris@679 116 QString getUserResourcePrefix();
Chris@680 117
Chris@680 118 /**
Chris@680 119 * Return the root paths for systemwide resource installations for
Chris@680 120 * this application.
Chris@680 121 */
Chris@679 122 QStringList getSystemResourcePrefixList();
Chris@680 123
Chris@680 124 /**
Chris@680 125 * Return all root paths for resource installations for this
Chris@680 126 * application, in the order in which they will be searched. This
Chris@680 127 * list consists of the user-specific path
Chris@680 128 * (getUserResourcePrefix()) followed by the systemwide paths
Chris@680 129 * (getSystemResourcePrefixList()).
Chris@680 130 */
Chris@679 131 QStringList getResourcePrefixList();
Chris@679 132 };
Chris@679 133
Chris@679 134 #endif
Chris@679 135
Chris@679 136