add ensure snapshot dir to SnapshotManager class... creating new snapshots with create_snapshot is broken as of this commit, will fix later

This commit is contained in:
Nikolaus Gullotta 2019-07-30 15:49:03 -05:00 committed by Nikolaus Gullotta
parent 8411fd17db
commit 5a3017153e
No known key found for this signature in database
GPG key ID: 565F60578092AA31
2 changed files with 14 additions and 3 deletions

View file

@ -49,7 +49,7 @@ public:
void refresh();
void clear() { _global_snapshots.clear(); _local_snapshots.clear(); };
private:
void ensure_snapshot_dir(bool global);
std::string _global_path;
std::string _local_path;

View file

@ -31,6 +31,7 @@
#include "pbd/basename.h"
#include "pbd/file_utils.h"
#include "pbd/gstdio_compat.h"
using namespace ARDOUR;
using namespace std;
@ -48,6 +49,14 @@ MixerSnapshotManager::MixerSnapshotManager (Session* s)
refresh();
}
void MixerSnapshotManager::ensure_snapshot_dir(bool global)
{
const string path = global ? _global_path : _local_path;
if(!Glib::file_test(path.c_str(), Glib::FILE_TEST_EXISTS & Glib::FILE_TEST_IS_DIR)) {
::g_mkdir(path.c_str(), 0775);
}
}
void MixerSnapshotManager::refresh()
{
clear();
@ -96,7 +105,8 @@ void MixerSnapshotManager::refresh()
void MixerSnapshotManager::create_snapshot(std::string const& label, RouteList& rl, bool global)
{
const string path = global?_global_path:_local_path;
ensure_snapshot_dir(global);
const string path = global ? _global_path : _local_path;
MixerSnapshot* snapshot = new MixerSnapshot(_session);
snapshot->snap(rl);
snapshot->set_label(label);
@ -113,7 +123,8 @@ void MixerSnapshotManager::create_snapshot(std::string const& label, RouteList&
void MixerSnapshotManager::create_snapshot(std::string const& label, std::string const& from_path, bool global)
{
const string path = global?_global_path:_local_path;
ensure_snapshot_dir(global);
const string path = global ? _global_path : _local_path;
MixerSnapshot* snapshot = new MixerSnapshot(_session, from_path);
snapshot->set_label(label);
snapshot->write(path);