#include <glibmm/miscutils.h>
#include <glibmm/fileutils.h>
-#include <glibmm/thread.h>
+#include <glibmm/threads.h>
#include "ardour/data_type.h"
#include "ardour/file_source.h"
FileSource::FileSource (Session& session, DataType type, const string& path, const string& origin, Source::Flag flag)
: Source(session, type, path, flag)
- , _path(path)
- , _file_is_new(true)
+ , _path (path)
+ , _file_is_new (!origin.empty()) // origin empty => new file VS. origin !empty => new file
, _channel (0)
, _origin (origin)
, _open (false)
{
_timeline_position = 0;
- if (Stateful::loading_state_version < 3000) {
- if (!find_2X (_session, _type, pathstr, must_exist, _file_is_new, _channel, _path)) {
- throw MissingSource (pathstr, _type);
- }
- } else {
- if (!find (_session, _type, pathstr, must_exist, _file_is_new, _channel, _path)) {
- throw MissingSource (pathstr, _type);
- }
- }
+ if (Stateful::loading_state_version < 3000) {
+ if (!find_2X (_session, _type, pathstr, must_exist, _file_is_new, _channel, _path)) {
+ throw MissingSource (pathstr, _type);
+ }
+ } else {
+ if (!find (_session, _type, pathstr, must_exist, _file_is_new, _channel, _path)) {
+ throw MissingSource (pathstr, _type);
+ }
+ }
set_within_session_from_path (_path);
-
+
_name = Glib::path_get_basename (_path);
- if (_file_is_new && must_exist) {
- return -1;
+ if (must_exist) {
+ if (!Glib::file_test (_path, Glib::FILE_TEST_EXISTS)) {
+ throw MissingSource (pathstr, _type);
+ }
}
return 0;
int
FileSource::set_source_name (const string& newname, bool destructive)
{
- Glib::Mutex::Lock lm (_lock);
+ Glib::Threads::Mutex::Lock lm (_lock);
string oldpath = _path;
string newpath = _session.change_source_path_by_name (oldpath, _name, newname, destructive);