Source: arts/dirmanager.h


Annotated List
Files
Globals
Hierarchy
Index
    /*

    Copyright (C) 2000 Stefan Westerfeld
                       stefan@space.twc.de

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.
  
    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.
   
    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.

    */

/*
 * BC - Status (2000-09-30): StandardDirs
 *
 * Is guaranteed to stay binary compatible. d ptr provided.
 */

#ifndef ARTS_DIRMANAGER_H
#define ARTS_DIRMANAGER_H

#include <string>
#include <vector>

namespace Arts {

class DirManagerPrivate;
class DirManager {
protected:
	friend class Dispatcher;

	DirManagerPrivate *d;
	static DirManager *instance;

public:
	/**
	 * constructor
	 */
	DirManager();

	/**
	 * destructor
	 */
	~DirManager();

	/**
	 * returns an instance
	 */
	static DirManager* the();

	/**
	 * This finds a specified resource, for instance
	 *
	 * <pre>
	 * DirManager::the()->locate("samples","pong.wav")
	 * DirManager::the()->locate("structures","stereo_beep.arts")
	 * </pre>
	 *
	 * would try to find a sample named pong.wav (or a structure named
	 * stereo_beep.arts) in the usual directories.
	 */
	std::string locate(const std::string& type, const std::string& filename);

	/**
	 * This is like locate, but returns all possible matches with a given
	 * extension, i.e.
	 *
	 * <pre>
	 * DirManager::the()->locateAll("samples","wav")
	 * </pre>
	 *
	 * would return all samples that have a wav extension.
	 */
	std::vector<std::string> *locateAll(const std::string& type,
								        const std::string& extension="",
								        bool recursive = false);

	/**
	 * This returns a directory where to save resources of a given type to.
	 *
	 * @param type      the type of the resource
	 * @param create    specifies whether the directory should be created
	 *
	 * @returns the directory to save the file to (with a / appended), or
	 *          nothing at all, if no writeable directory could be created
	 */
	std::string saveLocation(const std::string& type, bool create = true);
};

};
#endif /* ARTS_DIRMANAGER_H */

Generated by: stefan on stefan on Sat Jun 2 23:13:28 2001, using kdoc 2.0a53.