2 Copyright (C) 2006-2009 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __ardour_filesource_h__
21 #define __ardour_filesource_h__
25 #include "ardour/source.h"
29 class MissingSource : public std::exception {
31 virtual const char *what() const throw() { return "source file does not exist"; }
34 /** A source associated with a file on disk somewhere */
35 class FileSource : virtual public Source {
37 const Glib::ustring& path() const { return _path; }
39 virtual bool safe_file_extension (const Glib::ustring& path) const = 0;
41 int move_to_trash (const Glib::ustring& trash_dir_name);
42 void mark_take (const Glib::ustring& id);
43 void mark_immutable ();
45 const Glib::ustring& take_id () const { return _take_id; }
46 bool within_session () const { return _within_session; }
47 uint16_t channel() const { return _channel; }
49 int set_state (const XMLNode&, int version);
51 int set_source_name (const Glib::ustring& newname, bool destructive);
53 static void set_search_path (DataType type, const Glib::ustring& path);
55 static bool find (DataType type, const Glib::ustring& path,
56 bool must_exist, bool& is_new, uint16_t& chan,
57 Glib::ustring& found_path);
60 FileSource (Session& session, DataType type,
61 const Glib::ustring& path,
62 Source::Flag flags = Source::Flag(0));
64 FileSource (Session& session, const XMLNode& node, bool must_exist);
66 virtual int init (const Glib::ustring& idstr, bool must_exist);
68 virtual int move_dependents_to_trash() { return 0; }
69 void set_within_session_from_path (const std::string&);
71 bool removable () const;
74 Glib::ustring _take_id;
79 static std::map<DataType, Glib::ustring> search_paths;
84 #endif /* __ardour_filesource_h__ */