summaryrefslogtreecommitdiff
path: root/libs/pbd/pbd/file_utils.h
blob: ce5422db132ef8646e820c07552e409e0d36c4ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
    Copyright (C) 2007 Tim Mayberry 

    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
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*/

#ifndef PBD_FILE_UTILS_INCLUDED
#define PBD_FILE_UTILS_INCLUDED

#include <string>
#include <vector>

#include <glibmm/pattern.h>

#include "pbd/search_path.h"

namespace PBD {

using std::string;
using std::vector;

/**
 * Get a list of files in a directory.
 * @note You must join path with result to get the absolute path
 * to the file.
 *
 * @param path An Absolute path to a directory
 * @param result A vector of filenames.
 */
void
get_files_in_directory (const sys::path& path,
                        vector<string>& result);

/**
 * Takes a directory path and returns all the files in the directory
 * matching a particular pattern.
 *
 * @param directory A directory path
 * @param pattern A Glib::PatternSpec used to match the files.
 * @param result A vector in which to place the resulting matches.
 */
void
find_matching_files_in_directory (const sys::path& directory,
                                  const Glib::PatternSpec& pattern,
                                  vector<sys::path>& result);

/**
 * Takes a number of directory paths and returns all the files matching
 * a particular pattern.
 *
 * @param paths A vector containing the Absolute paths
 * @param pattern A Glib::PatternSpec used to match the files
 * @param result A vector in which to place the resulting matches.
 */
void
find_matching_files_in_directories (const vector<sys::path>& directory_paths,
                                    const Glib::PatternSpec& pattern,
                                    vector<sys::path>& result);

/**
 * Takes a SearchPath and puts a list of all the files in the search path
 * that match pattern into the result vector.
 *
 * @param search_path A SearchPath
 * @param pattern A Glib::PatternSpec used to match the files
 * @param result A vector in which to place the resulting matches.
 */
void
find_matching_files_in_search_path (const SearchPath& search_path,
                                    const Glib::PatternSpec& pattern,
                                    vector<sys::path>& result);

/**
 * Takes a search path and a file name and place the full path
 * to that file in result if it is found within the search path.
 *
 * @return true If file is found within the search path.
 */
bool
find_file_in_search_path (const SearchPath& search_path,
                          const string& filename,
                          sys::path& result);
			
} // namespace PBD

#endif