diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2007-04-06 23:42:07 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2007-04-06 23:42:07 +0000 |
commit | 2dd0b9321c87838e9f2276c02f5942daac2b836e (patch) | |
tree | 662e7204c0d3a3eea3183a9407a6b46871d0d152 /libs/ardour/audiofilesource.cc | |
parent | facf6168681010134085145b5b480d864d780cd4 (diff) |
modified fix from carl for region copy-moves-original-to-start bug; change verbose canvas cursor color to be more distinct and readable; fix naming issues with imported files containing ':'; make sure [N] channels count shows up for whole files in region list; fix #1575, a subtle and nasty bug; improve positioning of verbose canvas cursor for ruler drags (but has a wierd side effect
git-svn-id: svn://localhost/ardour2/trunk@1675 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/audiofilesource.cc')
-rw-r--r-- | libs/ardour/audiofilesource.cc | 117 |
1 files changed, 76 insertions, 41 deletions
diff --git a/libs/ardour/audiofilesource.cc b/libs/ardour/audiofilesource.cc index 929cfc8083..3a02c4c4b0 100644 --- a/libs/ardour/audiofilesource.cc +++ b/libs/ardour/audiofilesource.cc @@ -93,15 +93,17 @@ AudioFileSource::AudioFileSource (Session& s, ustring path, Flag flags, SampleFo AudioFileSource::AudioFileSource (Session& s, const XMLNode& node, bool must_exist) : AudioSource (s, node), _flags (Flag (Writable|CanRename)) - /* _channel is set in set_state() */ + /* _channel is set in set_state() or init() */ { /* constructor used for existing internal-to-session files. file must exist */ if (set_state (node)) { throw failed_constructor (); } + + string foo = _name; - if (init (_name, must_exist)) { + if (init (foo, must_exist)) { throw failed_constructor (); } } @@ -136,7 +138,7 @@ AudioFileSource::init (ustring pathstr, bool must_exist) _peaks_built = false; file_is_new = false; - if (!find (pathstr, must_exist, is_new)) { + if (!find (pathstr, must_exist, is_new, _channel)) { throw non_existent_source (); } @@ -361,42 +363,13 @@ AudioFileSource::move_to_trash (const ustring& trash_dir_name) } bool -AudioFileSource::find (ustring& pathstr, bool must_exist, bool& isnew) +AudioFileSource::find (ustring& pathstr, bool must_exist, bool& isnew, uint16_t& chan) { ustring::size_type pos; bool ret = false; isnew = false; - /* i (paul) made a nasty design error by using ':' as a special character in - Ardour 0.99 .. this hack tries to make things sort of work. - */ - - if ((pos = pathstr.find_last_of (':')) != ustring::npos) { - if (Glib::file_test (pathstr, Glib::FILE_TEST_EXISTS)) { - /* its a real file, no problem */ - - } else { - - if (must_exist) { - - /* older session using file:channel syntax */ - - warning << string_compose (_("This older session references an embedded\n\ -non-mono audio file:\n\n%1\n\n \ -The session file may be edited or the file must be removed before it can be used."), - short_path (pathstr, 48)) - << endmsg; - return false; - - } else { - - /* new derived file (e.g. for timefx) being created in a newer session */ - - } - } - } - if (pathstr[0] != '/') { /* non-absolute pathname: find pathstr in search path */ @@ -421,12 +394,60 @@ The session file may be edited or the file must be removed before it can be used if (fullpath[fullpath.length()-1] != '/') { fullpath += '/'; } + fullpath += pathstr; + + /* i (paul) made a nasty design error by using ':' as a special character in + Ardour 0.99 .. this hack tries to make things sort of work. + */ - if (access (fullpath.c_str(), R_OK) == 0) { - keeppath = fullpath; - ++cnt; - } + if ((pos = pathstr.find_last_of (':')) != ustring::npos) { + + if (Glib::file_test (fullpath, Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_REGULAR)) { + + /* its a real file, no problem */ + + keeppath = fullpath; + ++cnt; + + } else { + + if (must_exist) { + + /* might be an older session using file:channel syntax. see if the version + without the :suffix exists + */ + + ustring shorter = pathstr.substr (0, pos); + fullpath = *i; + + if (fullpath[fullpath.length()-1] != '/') { + fullpath += '/'; + } + + fullpath += shorter; + + if (Glib::file_test (pathstr, Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_REGULAR)) { + chan = atoi (pathstr.substr (pos+1)); + pathstr = shorter; + keeppath = fullpath; + ++cnt; + } + + } else { + + /* new derived file (e.g. for timefx) being created in a newer session */ + + } + } + + } else { + + if (Glib::file_test (fullpath, Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_REGULAR)) { + keeppath = fullpath; + ++cnt; + } + } } if (cnt > 1) { @@ -443,7 +464,7 @@ The session file may be edited or the file must be removed before it can be used isnew = true; } } - + _name = pathstr; _path = keeppath; ret = true; @@ -451,18 +472,31 @@ The session file may be edited or the file must be removed before it can be used } else { /* external files and/or very very old style sessions include full paths */ + + /* ugh, handle ':' situation */ + + if ((pos = pathstr.find_last_of (':')) != ustring::npos) { + + ustring shorter = pathstr.substr (0, pos); + + if (Glib::file_test (shorter, Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_REGULAR)) { + chan = atoi (pathstr.substr (pos+1)); + pathstr = shorter; + } + } _path = pathstr; + if (is_embedded()) { _name = pathstr; } else { _name = pathstr.substr (pathstr.find_last_of ('/') + 1); } - - if (access (_path.c_str(), R_OK) != 0) { - /* file does not exist or we cannot read it */ + if (!Glib::file_test (pathstr, Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_REGULAR)) { + /* file does not exist or we cannot read it */ + if (must_exist) { error << string_compose(_("Filesource: cannot find required file (%1): %2"), _path, strerror (errno)) << endmsg; goto out; @@ -483,6 +517,7 @@ The session file may be edited or the file must be removed before it can be used /* already exists */ ret = true; + } } |