| 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::scan_cvs_path(const fs::path& p) |
|---|
| 10 | */ |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | #include "bcp_imp.hpp" |
|---|
| 15 | #include "fileview.hpp" |
|---|
| 16 | #include <boost/regex.hpp> |
|---|
| 17 | #include <boost/filesystem/operations.hpp> |
|---|
| 18 | #include <boost/detail/workaround.hpp> |
|---|
| 19 | |
|---|
| 20 | void bcp_implementation::scan_cvs_path(const fs::path& p) |
|---|
| 21 | { |
|---|
| 22 | // |
|---|
| 23 | // scan through the cvs admin files to build a list |
|---|
| 24 | // of all the files under cvs version control |
|---|
| 25 | // and whether they are text or binary: |
|---|
| 26 | // |
|---|
| 27 | static const char* file_list[] = { "CVS/Entries", "CVS/Entries.Log" }; |
|---|
| 28 | static const boost::regex file_expression("^(?:A\\s+)?/([^/\\n]+)/[^/\\n]*/[^/\\n]*/[^k/\\n]*(kb[^/\\n]*)?/[^/\\n]*"); |
|---|
| 29 | static const boost::regex dir_expression("^(?:A\\s+)?D/([^/\\n]+)/"); |
|---|
| 30 | static const int file_subs[] = {1,2,}; |
|---|
| 31 | |
|---|
| 32 | for(int entry = 0; entry < sizeof(file_list)/sizeof(file_list[0]); ++entry) |
|---|
| 33 | { |
|---|
| 34 | fs::path entries(m_boost_path / p / file_list[entry]); |
|---|
| 35 | if(fs::exists(entries)) |
|---|
| 36 | { |
|---|
| 37 | fileview view(entries); |
|---|
| 38 | boost::regex_token_iterator<const char*> i(view.begin(), view.end(), dir_expression, 1); |
|---|
| 39 | boost::regex_token_iterator<const char*> j; |
|---|
| 40 | while(i != j) |
|---|
| 41 | { |
|---|
| 42 | fs::path recursion_dir(p / i->str()); |
|---|
| 43 | scan_cvs_path(recursion_dir); |
|---|
| 44 | ++i; |
|---|
| 45 | } |
|---|
| 46 | #if BOOST_WORKAROUND(BOOST_MSVC, < 1300) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)) |
|---|
| 47 | std::vector<int> v(file_subs, file_subs + 2); |
|---|
| 48 | i = boost::regex_token_iterator<const char*>(view.begin(), view.end(), file_expression, v); |
|---|
| 49 | #else |
|---|
| 50 | i = boost::regex_token_iterator<const char*>(view.begin(), view.end(), file_expression, file_subs); |
|---|
| 51 | #endif |
|---|
| 52 | while(i != j) |
|---|
| 53 | { |
|---|
| 54 | fs::path file = p / i->str(); |
|---|
| 55 | ++i; |
|---|
| 56 | bool binary = i->length() ? true : false; |
|---|
| 57 | ++i; |
|---|
| 58 | m_cvs_paths[file] = binary; |
|---|
| 59 | } |
|---|
| 60 | |
|---|
| 61 | } |
|---|
| 62 | } |
|---|
| 63 | } |
|---|