projects
/
ardour.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add automatable click-free bypass/enable feature to a-eq
[ardour.git]
/
libs
/
ardour
/
find_session.cc
diff --git
a/libs/ardour/find_session.cc
b/libs/ardour/find_session.cc
index 7a25b1298bf7cf7bba7d5aec4aab1d3fd7078c2b..af39a475277a940ae6d0fc95d5b4cb8c8d49de3a 100644
(file)
--- 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
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,22
+18,24
@@
*/
#include <unistd.h>
*/
#include <unistd.h>
-#include <sys/stat.h>
#include <cstring>
#include <climits>
#include <cerrno>
#include <cstring>
#include <climits>
#include <cerrno>
+#include "pbd/gstdio_compat.h"
+
#include <glibmm/miscutils.h>
#include "pbd/compose.h"
#include <glibmm/miscutils.h>
#include "pbd/compose.h"
+#include "pbd/pathexpand.h"
#include "pbd/error.h"
#include "ardour/filename_extensions.h"
#include "ardour/utils.h"
#include "ardour/session_utils.h"
#include "pbd/error.h"
#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;
using namespace std;
using namespace PBD;
@@
-43,21
+45,15
@@
namespace ARDOUR {
int
find_session (string str, string& path, string& snapshot, bool& isnew)
{
int
find_session (string str, string& path, string& snapshot, bool& isnew)
{
- struct stat statbuf;
- char buf[PATH_MAX+1];
+ GStatBuf statbuf;
isnew = false;
isnew = false;
- if (!realpath (str.c_str(), buf) && (errno != ENOENT && errno != ENOTDIR)) {
- error << string_compose (_("Could not resolve path: %1 (%2)"), buf, strerror(errno)) << endmsg;
- return -1;
- }
-
- str = buf;
+ str = canonical_path (str);
/* check to see if it exists, and what it is */
/* 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 {
if (errno == ENOENT) {
isnew = true;
} else {
@@
-86,7
+82,7
@@
find_session (string str, string& path, string& snapshot, bool& isnew)
/* is it there ? */
/* 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;
error << string_compose (_("cannot check statefile %1 (%2)"), tmp, strerror (errno))
<< endmsg;
return -1;
@@
-122,7
+118,10
@@
find_session (string str, string& path, string& snapshot, bool& isnew)
suffix = snapshot.find (statefile_suffix);
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;
}
error << string_compose (_("%1 is not a snapshot file"), str) << endmsg;
return -1;
}