• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *
3  * Copyright (c) 2003 Dr John Maddock
4  * Use, modification and distribution is subject to the
5  * Boost Software License, Version 1.0. (See accompanying file
6  * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7  *
8  * This file implements the following:
9  *    void bcp_implementation::is_source_file(const fs::path& p)
10  *    void bcp_implementation::is_html_file(const fs::path& p)
11  *    void bcp_implementation::is_binary_file(const fs::path& p)
12  */
13 
14 #include "bcp_imp.hpp"
15 #include <boost/regex.hpp>
16 
is_source_file(const fs::path & p)17 bool bcp_implementation::is_source_file(const fs::path& p)
18 {
19    static const boost::regex e(
20       ".*\\."
21       "(?:"
22          "c|cxx|h|hxx|inc|inl|.?pp|yy?"
23       ")",
24       boost::regex::perl | boost::regex::icase
25       );
26    return boost::regex_match(p.filename().generic_string(), e);
27 }
28 
is_html_file(const fs::path & p)29 bool bcp_implementation::is_html_file(const fs::path& p)
30 {
31    static const boost::regex e(
32       ".*\\."
33       "(?:"
34          "html?|css"
35       ")"
36       );
37    return boost::regex_match(p.filename().generic_string(), e);
38 }
39 
is_binary_file(const fs::path & p)40 bool bcp_implementation::is_binary_file(const fs::path& p)
41 {
42    if(m_cvs_mode || m_svn_mode)
43    {
44       std::map<fs::path, bool, path_less>::iterator pos = m_cvs_paths.find(p);
45       if(pos != m_cvs_paths.end()) return pos->second;
46    }
47    static const boost::regex e(
48       ".*\\."
49       "(?:"
50          "c|cxx|cpp|h|hxx|hpp|inc|html?|css|mak|in"
51       ")"
52       "|"
53       "(Jamfile|makefile|configure)",
54       boost::regex::perl | boost::regex::icase);
55    return !boost::regex_match(p.leaf().generic_string(), e);
56 
57 }
58 
is_jam_file(const fs::path & p)59 bool bcp_implementation::is_jam_file(const fs::path& p)
60 {
61    static const boost::regex e(
62       ".*\\."
63       "(?:"
64          "jam|v2"
65       ")"
66       "|"
67       "(Jamfile|Jamroot)\\.?",
68       boost::regex::perl | boost::regex::icase
69       );
70    return boost::regex_match(p.filename().generic_string(), e);
71 }
72 
73