#include <fcntl.h>
#include <errno.h>
-#include <pbd/convert.h>
-#include <pbd/basename.h>
-#include <pbd/mountpoint.h>
-#include <pbd/stl_delete.h>
-#include <pbd/strsplit.h>
-#include <pbd/shortpath.h>
-#include <pbd/enumwriter.h>
+#include "pbd/convert.h"
+#include "pbd/basename.h"
+#include "pbd/mountpoint.h"
+#include "pbd/stl_delete.h"
+#include "pbd/strsplit.h"
+#include "pbd/shortpath.h"
+#include "pbd/enumwriter.h"
#include <glibmm/miscutils.h>
#include <glibmm/fileutils.h>
#include <glibmm/thread.h>
-#include <ardour/file_source.h>
-#include <ardour/session.h>
-#include <ardour/session_directory.h>
-#include <ardour/source_factory.h>
-#include <ardour/filename_extensions.h>
+#include "ardour/file_source.h"
+#include "ardour/session.h"
+#include "ardour/session_directory.h"
+#include "ardour/source_factory.h"
+#include "ardour/filename_extensions.h"
#include "i18n.h"
+using namespace std;
using namespace ARDOUR;
using namespace PBD;
using namespace Glib;
{
return (_flags & Removable)
&& ( (_flags & RemoveAtDestroy)
- || ((_flags & RemovableIfEmpty) && length() == 0));
+ || ((_flags & RemovableIfEmpty) && length(timeline_position()) == 0));
}
int
FileSource::init (const ustring& pathstr, bool must_exist)
{
- _length = 0;
_timeline_position = 0;
- if (!find (_type, pathstr, must_exist, _file_is_new, _channel)) {
+ if (!find (_type, pathstr, must_exist, _file_is_new, _channel, _path)) {
throw MissingSource ();
}
+ /* XXX is this necessary? or even wise? */
+
+ if (_is_embedded) {
+ _name = Glib::path_get_basename (_name);
+ }
+
if (_file_is_new && must_exist) {
return -1;
}
return 0;
}
-/** Find the actual source file based on \a path.
+/** Find the actual source file based on \a filename.
*
- * If the source is embedded, \a path should be a filename (no slashes).
- * If the source is external, \a path should be a full path.
- * In either case, _path is set to the complete absolute path of the source file.
+ * If the source is embedded, \a filename should be a simple filename (no slashes).
+ * If the source is external, \a filename should be a full path.
+ * In either case, found_path is set to the complete absolute path of the source file.
* \return true iff the file was found.
*/
bool
-FileSource::find (DataType type, const ustring& path, bool must_exist, bool& isnew, uint16_t& chan)
+FileSource::find (DataType type, const ustring& path, bool must_exist,
+ bool& isnew, uint16_t& chan, ustring& found_path)
{
Glib::ustring search_path = search_paths[type];
}
}
- _path = keeppath;
+ found_path = keeppath;
ret = true;
}
}
- _path = pathstr;
+ found_path = pathstr;
if (!Glib::file_test (pathstr, Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_REGULAR)) {
if (must_exist) {
error << string_compose(
_("Filesource: cannot find required file (%1): %2"),
- _path, strerror (errno)) << endmsg;
+ path, strerror (errno)) << endmsg;
goto out;
}
if (errno != ENOENT) {
error << string_compose(
_("Filesource: cannot check for existing file (%1): %2"),
- _path, strerror (errno)) << endmsg;
+ path, strerror (errno)) << endmsg;
goto out;
}
}
}
- if (_is_embedded) {
- _name = Glib::path_get_basename (_name);
- }
-
out:
return ret;
}