mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-06 05:35:47 +01:00
Modify Session::path_from_region_name for portability
git-svn-id: svn://localhost/ardour2/trunk@2637 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
6dc5e02575
commit
3b32566d30
1 changed files with 8 additions and 7 deletions
|
|
@ -1573,23 +1573,24 @@ Session::path_from_region_name (DataType type, string name, string identifier)
|
|||
char buf[PATH_MAX+1];
|
||||
uint32_t n;
|
||||
SessionDirectory sdir(get_best_session_directory_for_new_source());
|
||||
string sound_dir = ((type == DataType::AUDIO)
|
||||
? sdir.sound_path().to_string()
|
||||
: sdir.midi_path().to_string());
|
||||
sys::path source_dir = ((type == DataType::AUDIO)
|
||||
? sdir.sound_path() : sdir.midi_path());
|
||||
|
||||
string ext = ((type == DataType::AUDIO) ? ".wav" : ".mid");
|
||||
|
||||
for (n = 0; n < 999999; ++n) {
|
||||
if (identifier.length()) {
|
||||
snprintf (buf, sizeof(buf), "%s/%s%s%" PRIu32 "%s", sound_dir.c_str(), name.c_str(),
|
||||
snprintf (buf, sizeof(buf), "%s%s%" PRIu32 "%s", name.c_str(),
|
||||
identifier.c_str(), n, ext.c_str());
|
||||
} else {
|
||||
snprintf (buf, sizeof(buf), "%s/%s-%" PRIu32 "%s", sound_dir.c_str(), name.c_str(),
|
||||
snprintf (buf, sizeof(buf), "%s-%" PRIu32 "%s", name.c_str(),
|
||||
n, ext.c_str());
|
||||
}
|
||||
|
||||
if (!sys::exists (buf)) {
|
||||
return buf;
|
||||
sys::path source_path = source_dir / buf;
|
||||
|
||||
if (!sys::exists (source_path)) {
|
||||
return source_path.to_string();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue