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__
27 #include "ardour/source.h"
31 class MissingSource : public std::exception
34 MissingSource (const std::string& p, DataType t) throw ()
35 : path (p), type (t) {}
36 ~MissingSource() throw() {}
38 virtual const char *what() const throw() { return "source file does not exist"; }
44 /** A source associated with a file on disk somewhere */
45 class FileSource : virtual public Source {
47 virtual ~FileSource () {}
49 const std::string& path() const { return _path; }
54 virtual bool safe_file_extension (const std::string& path) const = 0;
56 int move_to_trash (const std::string& trash_dir_name);
57 void mark_take (const std::string& id);
58 void mark_immutable ();
59 void mark_nonremovable ();
61 const std::string& take_id () const { return _take_id; }
62 bool within_session () const { return _within_session; }
63 uint16_t channel() const { return _channel; }
65 int set_state (const XMLNode&, int version);
67 int set_source_name (const std::string& newname, bool destructive);
69 static bool find (Session&, DataType type, const std::string& path,
70 bool must_exist, bool& is_new, uint16_t& chan,
71 std::string& found_path);
73 static bool find_2X (Session&, DataType type, const std::string& path,
74 bool must_exist, bool& is_new, uint16_t& chan,
75 std::string& found_path);
77 void inc_use_count ();
78 bool removable () const;
80 const std::string& origin() const { return _origin; }
82 static PBD::Signal3<int,std::string,std::string,std::vector<std::string> > AmbiguousFileName;
85 FileSource (Session& session, DataType type,
86 const std::string& path,
87 const std::string& origin,
88 Source::Flag flags = Source::Flag(0));
90 FileSource (Session& session, const XMLNode& node, bool must_exist);
92 virtual int init (const std::string& idstr, bool must_exist);
94 virtual void set_path (const std::string&);
95 virtual int move_dependents_to_trash() { return 0; }
96 void set_within_session_from_path (const std::string&);
102 bool _within_session;
105 void prevent_deletion ();
108 } // namespace ARDOUR
110 #endif /* __ardour_filesource_h__ */