summaryrefslogtreecommitdiff
path: root/libs/ardour/file_source.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2010-11-09 17:24:17 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2010-11-09 17:24:17 +0000
commit7ae1a99d067aa3e1510902e3e20575165cb58b5c (patch)
tree361997b5e285bd94fb5f613b2d7630fbb83ee731 /libs/ardour/file_source.cc
parent5c6ba165f684fbd45be33c83d41083567d4dd88f (diff)
always store source names as relative paths; always add directories of embedded files to search path; never use hardlinks for embedding anymore
git-svn-id: svn://localhost/ardour2/branches/3.0@7984 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/file_source.cc')
-rw-r--r--libs/ardour/file_source.cc105
1 files changed, 53 insertions, 52 deletions
diff --git a/libs/ardour/file_source.cc b/libs/ardour/file_source.cc
index 95ab3e9f3d..7eac1a23ea 100644
--- a/libs/ardour/file_source.cc
+++ b/libs/ardour/file_source.cc
@@ -104,9 +104,11 @@ FileSource::init (const string& pathstr, bool must_exist)
set_within_session_from_path (pathstr);
- if (_within_session) {
- _name = Glib::path_get_basename (_name);
- }
+ if (!within_session()) {
+ _session.ensure_search_path_includes (Glib::path_get_dirname (pathstr), _type);
+ }
+
+ _name = Glib::path_get_basename (pathstr);
if (_file_is_new && must_exist) {
return -1;
@@ -211,64 +213,63 @@ bool
FileSource::find (Session& s, DataType type, const string& path, bool must_exist,
bool& isnew, uint16_t& chan, string& found_path)
{
- string search_path = s.source_search_path (type);
-
- string pathstr = path;
bool ret = false;
-
- cerr << "Searching along " << search_path << endl;
+ string keeppath;
isnew = false;
-
- vector<string> dirs;
- vector<string> hits;
- int cnt;
- string fullpath;
- string keeppath;
-
- if (search_path.length() == 0) {
- error << _("FileSource: search path not set") << endmsg;
- goto out;
- }
-
- split (search_path, dirs, ':');
-
- cnt = 0;
- hits.clear ();
-
- for (vector<string>::iterator i = dirs.begin(); i != dirs.end(); ++i) {
-
- cerr << "Searching in " << *i << " for " << pathstr << endl;
-
- fullpath = Glib::build_filename (*i, pathstr);
-
- if (Glib::file_test (fullpath, Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_REGULAR)) {
- keeppath = fullpath;
- hits.push_back (fullpath);
- ++cnt;
- }
- }
- if (cnt > 1) {
-
- int which = FileSource::AmbiguousFileName (pathstr, search_path, hits).get_value_or (-1);
+ if (!Glib::path_is_absolute (path)) {
+ vector<string> dirs;
+ vector<string> hits;
+ int cnt;
+ string fullpath;
- if (which < 0) {
+ string search_path = s.source_search_path (type);
+
+ if (search_path.length() == 0) {
+ error << _("FileSource: search path not set") << endmsg;
goto out;
- } else {
- keeppath = hits[which];
}
+
+ split (search_path, dirs, ':');
- } else if (cnt == 0) {
+ cnt = 0;
+ hits.clear ();
- if (must_exist) {
- error << string_compose(
- _("Filesource: cannot find required file (%1): while searching %2"),
- pathstr, search_path) << endmsg;
- goto out;
- } else {
- isnew = true;
+ for (vector<string>::iterator i = dirs.begin(); i != dirs.end(); ++i) {
+
+ fullpath = Glib::build_filename (*i, path);
+
+ if (Glib::file_test (fullpath, Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_REGULAR)) {
+ keeppath = fullpath;
+ hits.push_back (fullpath);
+ ++cnt;
+ }
}
+
+ if (cnt > 1) {
+
+ int which = FileSource::AmbiguousFileName (path, search_path, hits).get_value_or (-1);
+
+ if (which < 0) {
+ goto out;
+ } else {
+ keeppath = hits[which];
+ }
+
+ } else if (cnt == 0) {
+
+ if (must_exist) {
+ error << string_compose(
+ _("Filesource: cannot find required file (%1): while searching %2"),
+ path, search_path) << endmsg;
+ goto out;
+ } else {
+ isnew = true;
+ }
+ }
+ } else {
+ keeppath = path;
}
/* Current find() is unable to parse relative path names to yet non-existant
@@ -278,7 +279,7 @@ FileSource::find (Session& s, DataType type, const string& path, bool must_exist
if (must_exist) {
error << "FileSource::find(), keeppath = \"\", but the file must exist" << endl;
} else {
- keeppath = pathstr;
+ keeppath = path;
}
}