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>
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.
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.
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.
23 #include <glibmm/fileutils.h>
25 #include <giomm/file.h>
27 #include "pbd/basename.h"
28 #include "pbd/compose.h"
29 #include "pbd/error.h"
30 #include "pbd/file_utils.h"
32 #include "ardour/session_state_utils.h"
33 #include "ardour/filename_extensions.h"
43 create_backup_file (const std::string & file_path)
45 return copy_file (file_path, file_path + backup_suffix);
49 get_state_files_in_directory (const std::string & directory_path,
50 vector<std::string> & result)
52 find_files_matching_pattern (result, directory_path,
53 '*' + string(statefile_suffix));
57 get_file_names_no_extension (const vector<std::string> & file_paths)
59 vector<string> result;
61 std::transform (file_paths.begin(), file_paths.end(),
62 std::back_inserter(result), PBD::basename_nosuffix);
64 sort (result.begin(), result.end(), std::less<string>());