diff options
author | Sampo Savolainen <v2@iki.fi> | 2006-10-27 22:48:19 +0000 |
---|---|---|
committer | Sampo Savolainen <v2@iki.fi> | 2006-10-27 22:48:19 +0000 |
commit | 674e73ae77480ef851374dae79e7c5c023f04635 (patch) | |
tree | b77ee49f186601e5d3184474fcc56f826f67a83f /libs/ardour/audiofilesource.cc | |
parent | 1bd4c5b3a212460eed1773f6b049d18c89625565 (diff) |
Embedded files / embedding files now work.
git-svn-id: svn://localhost/ardour2/trunk@1032 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/audiofilesource.cc')
-rw-r--r-- | libs/ardour/audiofilesource.cc | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/libs/ardour/audiofilesource.cc b/libs/ardour/audiofilesource.cc index 77709e3a3c..8fe6c845c0 100644 --- a/libs/ardour/audiofilesource.cc +++ b/libs/ardour/audiofilesource.cc @@ -66,6 +66,7 @@ AudioFileSource::AudioFileSource (Session& s, string idstr, Flag flags) : AudioSource (s, idstr), _flags (flags) { /* constructor used for existing external to session files. file must exist already */ + _is_embedded = AudioFileSource::determine_embeddedness (idstr); if (init (idstr, true)) { throw failed_constructor (); @@ -77,6 +78,7 @@ AudioFileSource::AudioFileSource (Session& s, std::string path, Flag flags, Samp : AudioSource (s, path), _flags (flags) { /* constructor used for new internal-to-session files. file cannot exist */ + _is_embedded = false; if (init (path, false)) { throw failed_constructor (); @@ -106,6 +108,12 @@ AudioFileSource::~AudioFileSource () } bool +AudioFileSource::determine_embeddedness (std::string path) +{ + return (path.find("/") == 0); +} + +bool AudioFileSource::removable () const { return (_flags & Removable) && ((_flags & RemoveAtDestroy) || ((_flags & RemovableIfEmpty) && length() == 0)); @@ -277,6 +285,12 @@ AudioFileSource::set_state (const XMLNode& node) } + if ((prop = node.property (X_("name"))) != 0) { + _is_embedded = AudioFileSource::determine_embeddedness (prop->value()); + } else { + _is_embedded = false; + } + return 0; } @@ -318,6 +332,11 @@ AudioFileSource::mark_take (string id) int AudioFileSource::move_to_trash (const string trash_dir_name) { + if (is_embedded()) { + cerr << "tried to move an embedded region to trash" << endl; + return -1; + } + string newpath; if (!writable()) { @@ -465,7 +484,11 @@ AudioFileSource::find (string pathstr, bool must_exist, bool& isnew) /* external files and/or very very old style sessions include full paths */ _path = pathstr; - _name = pathstr.substr (pathstr.find_last_of ('/') + 1); + if (is_embedded()) { + _name = pathstr; + } else { + _name = pathstr.substr (pathstr.find_last_of ('/') + 1); + } if (access (_path.c_str(), R_OK) != 0) { |