X-Git-Url: https://main.carlh.net/gitweb/?p=ardour.git;a=blobdiff_plain;f=libs%2Fardour%2Ffind_session.cc;h=af39a475277a940ae6d0fc95d5b4cb8c8d49de3a;hp=afcbe7393b0f50c32e06fb0e6630d16b9e44b808;hb=c8c6bca6587450ff64303dbc994a4cd28d6ce7aa;hpb=d135c4dc3a307d0be606f3afbbc8fd8c3ec56438 diff --git a/libs/ardour/find_session.cc b/libs/ardour/find_session.cc index afcbe7393b..af39a47527 100644 --- a/libs/ardour/find_session.cc +++ b/libs/ardour/find_session.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Paul Davis + Copyright (C) 2012 Paul Davis This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,12 +18,13 @@ */ #include -#include #include #include #include +#include "pbd/gstdio_compat.h" + #include #include "pbd/compose.h" @@ -32,8 +33,9 @@ #include "ardour/filename_extensions.h" #include "ardour/utils.h" +#include "ardour/session_utils.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace std; using namespace PBD; @@ -43,7 +45,7 @@ namespace ARDOUR { int find_session (string str, string& path, string& snapshot, bool& isnew) { - struct stat statbuf; + GStatBuf statbuf; isnew = false; @@ -51,7 +53,7 @@ find_session (string str, string& path, string& snapshot, bool& isnew) /* check to see if it exists, and what it is */ - if (stat (str.c_str(), &statbuf)) { + if (g_stat (str.c_str(), &statbuf)) { if (errno == ENOENT) { isnew = true; } else { @@ -80,7 +82,7 @@ find_session (string str, string& path, string& snapshot, bool& isnew) /* is it there ? */ - if (stat (tmp.c_str(), &statbuf)) { + if (g_stat (tmp.c_str(), &statbuf)) { error << string_compose (_("cannot check statefile %1 (%2)"), tmp, strerror (errno)) << endmsg; return -1; @@ -116,7 +118,10 @@ find_session (string str, string& path, string& snapshot, bool& isnew) suffix = snapshot.find (statefile_suffix); - if (suffix == string::npos) { + const string::size_type start_pos_of_extension = snapshot.size () - strlen (statefile_suffix); + // we should check the start of extension position + // because files '*.ardour.bak' are possible + if (suffix != start_pos_of_extension) { error << string_compose (_("%1 is not a snapshot file"), str) << endmsg; return -1; }