use a note tracker to resolve notes cut off during render by the end of the region
[ardour.git] / libs / ardour / session_state_utils.cc
1 /*
2  * Copyright (C) 2007-2014 Tim Mayberry <mojofunk@gmail.com>
3  * Copyright (C) 2008-2016 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2009 David Robillard <d@drobilla.net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20
21 #include <algorithm>
22
23 #include <glibmm/fileutils.h>
24
25 #include <giomm/file.h>
26
27 #include "pbd/basename.h"
28 #include "pbd/compose.h"
29 #include "pbd/error.h"
30 #include "pbd/file_utils.h"
31
32 #include "ardour/session_state_utils.h"
33 #include "ardour/filename_extensions.h"
34
35 #include "pbd/i18n.h"
36
37 using namespace std;
38 using namespace PBD;
39
40 namespace ARDOUR {
41
42 bool
43 create_backup_file (const std::string & file_path)
44 {
45         return copy_file (file_path, file_path + backup_suffix);
46 }
47
48 void
49 get_state_files_in_directory (const std::string & directory_path,
50                               vector<std::string> & result)
51 {
52         find_files_matching_pattern (result, directory_path,
53                                      '*' + string(statefile_suffix));
54 }
55
56 vector<string>
57 get_file_names_no_extension (const vector<std::string> & file_paths)
58 {
59         vector<string> result;
60
61         std::transform (file_paths.begin(), file_paths.end(),
62                         std::back_inserter(result), PBD::basename_nosuffix);
63
64         sort (result.begin(), result.end(), std::less<string>());
65
66         return result;
67 }
68
69 } // namespace ARDOUR