]> git.lyx.org Git - lyx.git/blob - src/support/globbing.h
809aae6bc1eb677ae3d5ffa26b7d2af19bfccee8
[lyx.git] / src / support / globbing.h
1 // -*- C++ -*-
2 /**
3  * \file globbing.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Angus Leeming
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef GLOBBING_H
13 #define GLOBBING_H
14
15 #include <string>
16 #include <vector>
17
18 namespace lyx {
19 namespace support {
20
21 /** Given a string such as
22  *      "<glob> <glob> ... *.{abc,def} <glob>",
23  *  convert the csh-style brace expresions:
24  *      "<glob> <glob> ... *.abc *.def <glob>".
25  *  Requires no system support, so should work equally on Unix, Mac, Win32.
26  */
27 std::string const convert_brace_glob(std::string const & glob);
28
29 /** A wrapper for the Posix function 'glob'.
30  *  \param pattern the glob to be expanded. Eg "*.[Ch]".
31  *  \param flags flags to be passed to the system function. See 'man glob'.
32  *  \returns a vector of the files found to match \c pattern.
33  */
34 std::vector<std::string> const glob(std::string const & pattern, int flags = 0);
35
36 /** Given a string "<glob> <glob> <glob>", expand each glob in turn.
37  *  Any glob that cannot be expanded is ignored silently.
38  *  Invokes \c expand_brace_glob and \c glob internally, so use only
39  *  on systems supporting the Posix function 'glob'.
40  * \param mask the string "<glob> <glob> <glob>".
41  * \param directory (if not empty) the current working directory from
42  * which \c glob is invoked.
43  *  \returns a vector of all matching file names.
44  */
45 std::vector<std::string> const
46 expand_globs(std::string const & mask,
47              std::string const & directory = std::string());
48
49 } // namespace support
50 } // namespace lyx
51
52 #endif // NOT GLOBBING_H