Move file suffixes out of the Session class and into filename_extensions.h/cc

git-svn-id: svn://localhost/ardour2/trunk@1864 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Tim Mayberry 2007-05-18 02:41:36 +00:00
parent 1315ee3dff
commit 09d6a96321
6 changed files with 50 additions and 37 deletions

View File

@ -29,6 +29,7 @@ ardour.Append(CPPPATH = '#libs/surfaces/control_protocol')
ardour_files=Split("""
chan_count.cc
diskstream.cc
filename_extensions.cc
track.cc
audio_diskstream.cc
audio_library.cc

View File

@ -0,0 +1,13 @@
#ifndef __ardour_filename_extensions_h__
#define __ardour_filename_extensions_h__
namespace ARDOUR {
extern const char* const template_suffix;
extern const char* const statefile_suffix;
extern const char* const pending_suffix;
}
#endif

View File

@ -907,12 +907,6 @@ class Session : public PBD::StatefulDestructible
static int read_favorite_dirs (FavoriteDirs&);
static int write_favorite_dirs (FavoriteDirs&);
/* file suffixes */
static const char* template_suffix() { return _template_suffix; }
static const char* statefile_suffix() { return _statefile_suffix; }
static const char* pending_suffix() { return _pending_suffix; }
/* buffers for gain and pan */
@ -965,10 +959,6 @@ class Session : public PBD::StatefulDestructible
nframes_t compute_initial_length ();
static const char* _template_suffix;
static const char* _statefile_suffix;
static const char* _pending_suffix;
enum SubState {
PendingDeclickIn = 0x1,
PendingDeclickOut = 0x2,

View File

@ -0,0 +1,11 @@
#include <ardour/filename_extensions.h>
#include "i18n.h"
namespace ARDOUR {
const char* const template_suffix = X_(".template");
const char* const statefile_suffix = X_(".ardour");
const char* const pending_suffix = X_(".pending");
}

View File

@ -72,6 +72,7 @@
#include <ardour/buffer_set.h>
#include <ardour/source_factory.h>
#include <ardour/region_factory.h>
#include <ardour/filename_extensions.h>
#ifdef HAVE_LIBLO
#include <ardour/osc.h>
@ -90,9 +91,6 @@ static const int CPU_CACHE_ALIGN = 64;
static const int CPU_CACHE_ALIGN = 16; /* arguably 32 on most arches, but it matters less */
#endif
const char* Session::_template_suffix = X_(".template");
const char* Session::_statefile_suffix = X_(".ardour");
const char* Session::_pending_suffix = X_(".pending");
const char* Session::old_sound_dir_name = X_("sounds");
const char* Session::sound_dir_name = X_("audiofiles");
const char* Session::peak_dir_name = X_("peaks");
@ -153,7 +151,7 @@ Session::find_session (string str, string& path, string& snapshot, bool& isnew)
tmp = str;
tmp += '/';
tmp += str;
tmp += _statefile_suffix;
tmp += statefile_suffix;
/* is it there ? */
@ -191,7 +189,7 @@ Session::find_session (string str, string& path, string& snapshot, bool& isnew)
snapshot = str;
}
suffix = snapshot.find (_statefile_suffix);
suffix = snapshot.find (statefile_suffix);
if (suffix == string::npos) {
error << string_compose (_("%1 is not an Ardour snapshot file"), str) << endmsg;

View File

@ -96,7 +96,7 @@
#include <ardour/region_factory.h>
#include <ardour/source_factory.h>
#include <ardour/playlist_factory.h>
#include <ardour/filename_extensions.h>
#include <control_protocol/control_protocol.h>
#include "i18n.h"
@ -517,7 +517,7 @@ Session::create (bool& new_session, string* mix_template, nframes_t initial_leng
if (in){
string out_path = _path;
out_path += _name;
out_path += _statefile_suffix;
out_path += statefile_suffix;
ofstream out(out_path.c_str());
@ -608,7 +608,7 @@ Session::remove_pending_capture_state ()
xml_path = _path;
xml_path += _current_snapshot_name;
xml_path += _pending_suffix;
xml_path += pending_suffix;
unlink (xml_path.c_str());
}
@ -624,8 +624,8 @@ Session::rename_state (string old_name, string new_name)
return;
}
const string old_xml_path = _path + old_name + _statefile_suffix;
const string new_xml_path = _path + new_name + _statefile_suffix;
const string old_xml_path = _path + old_name + statefile_suffix;
const string new_xml_path = _path + new_name + statefile_suffix;
if (rename (old_xml_path.c_str(), new_xml_path.c_str()) != 0) {
error << string_compose(_("could not rename snapshot %1 to %2"), old_name, new_name) << endmsg;
@ -643,7 +643,7 @@ Session::remove_state (string snapshot_name)
return;
}
const string xml_path = _path + snapshot_name + _statefile_suffix;
const string xml_path = _path + snapshot_name + statefile_suffix;
/* make a backup copy of the state file */
const string bak_path = xml_path + ".bak";
@ -680,10 +680,10 @@ Session::save_state (string snapshot_name, bool pending)
if (!pending) {
/* proper save: use _statefile_suffix (.ardour in English) */
/* proper save: use statefile_suffix (.ardour in English) */
xml_path = _path;
xml_path += snapshot_name;
xml_path += _statefile_suffix;
xml_path += statefile_suffix;
/* make a backup copy of the old file */
bak_path = xml_path;
@ -695,10 +695,10 @@ Session::save_state (string snapshot_name, bool pending)
} else {
/* pending save: use _pending_suffix (.pending in English) */
/* pending save: use pending_suffix (.pending in English) */
xml_path = _path;
xml_path += snapshot_name;
xml_path += _pending_suffix;
xml_path += pending_suffix;
}
@ -768,7 +768,7 @@ Session::load_state (string snapshot_name)
xmlpath = _path;
xmlpath += snapshot_name;
xmlpath += _pending_suffix;
xmlpath += pending_suffix;
if (Glib::file_test (xmlpath, Glib::FILE_TEST_EXISTS)) {
@ -783,7 +783,7 @@ Session::load_state (string snapshot_name)
xmlpath = _path;
xmlpath += snapshot_name;
xmlpath += _statefile_suffix;
xmlpath += statefile_suffix;
}
if (!Glib::file_test (xmlpath, Glib::FILE_TEST_EXISTS)) {
@ -831,7 +831,7 @@ Session::load_state (string snapshot_name)
backup_path = _path;
backup_path += snapshot_name;
backup_path += "-1";
backup_path += _statefile_suffix;
backup_path += statefile_suffix;
info << string_compose (_("Copying old session file %1 to %2\nUse %2 with Ardour versions before 2.0 from now on"),
xmlpath, backup_path)
@ -1700,7 +1700,7 @@ Session::save_template (string template_name)
xml_path = dir;
xml_path += template_name;
xml_path += _template_suffix;
xml_path += template_suffix;
ifstream in(xml_path.c_str());
@ -1722,8 +1722,8 @@ Session::save_template (string template_name)
int
Session::rename_template (string old_name, string new_name)
{
string old_path = template_dir() + old_name + _template_suffix;
string new_path = template_dir() + new_name + _template_suffix;
string old_path = template_dir() + old_name + template_suffix;
string new_path = template_dir() + new_name + template_suffix;
return rename (old_path.c_str(), new_path.c_str());
}
@ -1733,7 +1733,7 @@ Session::delete_template (string name)
{
string template_path = template_dir();
template_path += name;
template_path += _template_suffix;
template_path += template_suffix;
return remove (template_path.c_str());
}
@ -2228,8 +2228,8 @@ Session::load_route_groups (const XMLNode& node, bool edit)
static bool
state_file_filter (const string &str, void *arg)
{
return (str.length() > strlen(Session::statefile_suffix()) &&
str.find (Session::statefile_suffix()) == (str.length() - strlen (Session::statefile_suffix())));
return (str.length() > strlen(statefile_suffix) &&
str.find (statefile_suffix) == (str.length() - strlen (statefile_suffix)));
}
struct string_cmp {
@ -2492,8 +2492,8 @@ Session::global_record_enable_memento (void* src)
static bool
template_filter (const string &str, void *arg)
{
return (str.length() > strlen(Session::template_suffix()) &&
str.find (Session::template_suffix()) == (str.length() - strlen (Session::template_suffix())));
return (str.length() > strlen(template_suffix) &&
str.find (template_suffix) == (str.length() - strlen (template_suffix)));
}
void
@ -2657,7 +2657,7 @@ Session::find_all_sources_across_snapshots (set<string>& result, bool exclude_th
this_snapshot_path = _path;
this_snapshot_path += _current_snapshot_name;
this_snapshot_path += _statefile_suffix;
this_snapshot_path += statefile_suffix;
for (vector<string*>::iterator i = state_files->begin(); i != state_files->end(); ++i) {