ardour
session_state_utils.cc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2007 Tim Mayberry
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18 
19 #include <algorithm>
20 
21 #include <glibmm/fileutils.h>
22 
23 #include <giomm/file.h>
24 
25 #include "pbd/basename.h"
26 #include "pbd/compose.h"
27 #include "pbd/error.h"
28 #include "pbd/file_utils.h"
29 
32 
33 #include "i18n.h"
34 
35 using namespace std;
36 using namespace PBD;
37 
38 namespace ARDOUR {
39 
40 bool
41 create_backup_file (const std::string & file_path)
42 {
43  return copy_file (file_path, file_path + backup_suffix);
44 }
45 
46 void
47 get_state_files_in_directory (const std::string & directory_path,
48  vector<std::string> & result)
49 {
50  find_files_matching_pattern (result, directory_path,
51  '*' + string(statefile_suffix));
52 }
53 
54 vector<string>
55 get_file_names_no_extension (const vector<std::string> & file_paths)
56 {
57  vector<string> result;
58 
59  std::transform (file_paths.begin(), file_paths.end(),
60  std::back_inserter(result), PBD::basename_nosuffix);
61 
62  sort (result.begin(), result.end(), std::less<string>());
63 
64  return result;
65 }
66 
67 } // namespace ARDOUR
void get_state_files_in_directory(const std::string &directory_path, vector< std::string > &result)
Definition: Beats.hpp:239
LIBARDOUR_API bool create_backup_file(const std::string &file_path)
bool copy_file(const std::string &from_path, const std::string &to_path)
Definition: file_utils.cc:282
void find_files_matching_pattern(vector< string > &result, const Searchpath &paths, const Glib::PatternSpec &pattern)
Definition: file_utils.cc:168
Definition: amp.h:29
LIBARDOUR_API const char *const backup_suffix
LIBARDOUR_API const char *const statefile_suffix
LIBPBD_API Glib::ustring basename_nosuffix(Glib::ustring)
vector< string > get_file_names_no_extension(const vector< std::string > &file_paths)
Definition: debug.h:30