+ bool ret = false;
+ string keeppath;
+
+ isnew = false;
+
+ if (!Glib::path_is_absolute (path)) {
+ vector<string> dirs;
+ vector<string> hits;
+ string fullpath;
+
+ string search_path = s.source_search_path (type);
+
+ if (search_path.length() == 0) {
+ error << _("FileSource: search path not set") << endmsg;
+ goto out;
+ }
+
+ split (search_path, dirs, ':');
+
+ hits.clear ();
+
+ 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);
+ }
+ }
+
+ /* Remove duplicate inodes from the list of ambiguous files, since if there are symlinks
+ in the session path it is possible to arrive at the same file via more than one path.
+
+ I suppose this is not necessary on Windows.
+ */
+
+ vector<string> de_duped_hits;
+
+ for (vector<string>::iterator i = hits.begin(); i != hits.end(); ++i) {
+
+ vector<string>::iterator j = i;
+ ++j;
+
+ while (j != hits.end()) {
+ if (PBD::equivalent_paths (*i, *j)) {
+ /* *i and *j are the same file; break out of the loop early */
+ break;
+ }
+
+ ++j;
+ }
+
+ if (j == hits.end ()) {
+ de_duped_hits.push_back (*i);
+ }
+ }
+
+ if (de_duped_hits.size() > 1) {
+
+ /* more than one match: ask the user */
+
+ int which = FileSource::AmbiguousFileName (path, search_path, de_duped_hits).get_value_or (-1);
+
+ if (which < 0) {
+ goto out;
+ } else {
+ keeppath = de_duped_hits[which];
+ }
+
+ } else if (de_duped_hits.size() == 0) {