|
| 1 | +From cd21e9b4a749a77c24facf2da44f01e032c40842 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Andrey Semashev < [email protected]> |
| 3 | +Date: Sun, 24 Mar 2024 14:49:18 +0300 |
| 4 | +Subject: [PATCH] Remove usage of deprecated and removed Boost.Filesystem APIs. |
| 5 | + |
| 6 | +--- |
| 7 | + add_dependent_lib.cpp | 5 +++-- |
| 8 | + add_path.cpp | 30 +++++++++++++++--------------- |
| 9 | + bcp_imp.hpp | 1 + |
| 10 | + copy_path.cpp | 8 ++++---- |
| 11 | + file_types.cpp | 2 +- |
| 12 | + 5 files changed, 24 insertions(+), 22 deletions(-) |
| 13 | + |
| 14 | +diff --git a/add_dependent_lib.cpp b/add_dependent_lib.cpp |
| 15 | +index 4852914..521b70d 100644 |
| 16 | +--- a/add_dependent_lib.cpp |
| 17 | ++++ b/add_dependent_lib.cpp |
| 18 | +@@ -15,6 +15,7 @@ |
| 19 | + #include "bcp_imp.hpp" |
| 20 | + #include "fileview.hpp" |
| 21 | + #include <boost/regex.hpp> |
| 22 | ++#include <boost/filesystem/directory.hpp> |
| 23 | + #include <boost/filesystem/operations.hpp> |
| 24 | + #include <boost/filesystem/exception.hpp> |
| 25 | + #include <iostream> |
| 26 | +@@ -43,12 +44,12 @@ static void init_library_scanner(const fs::path& p, bool cvs_mode, const std::st |
| 27 | + // |
| 28 | + // Don't add files created by build system: |
| 29 | + // |
| 30 | +- if((p.leaf() == "bin") || (p.leaf() == "bin-stage")) |
| 31 | ++ if((p.filename() == "bin") || (p.filename() == "bin-stage")) |
| 32 | + return; |
| 33 | + // |
| 34 | + // Don't add version control directories: |
| 35 | + // |
| 36 | +- if((p.leaf() == "CVS") || (p.leaf() == ".svn")) |
| 37 | ++ if((p.filename() == "CVS") || (p.filename() == ".svn")) |
| 38 | + return; |
| 39 | + // |
| 40 | + // don't add directories not under version control: |
| 41 | +diff --git a/add_path.cpp b/add_path.cpp |
| 42 | +index 8a1fee3..747bb8c 100644 |
| 43 | +--- a/add_path.cpp |
| 44 | ++++ b/add_path.cpp |
| 45 | +@@ -15,6 +15,7 @@ |
| 46 | + #include "bcp_imp.hpp" |
| 47 | + #include "fileview.hpp" |
| 48 | + #include <boost/regex.hpp> |
| 49 | ++#include <boost/filesystem/directory.hpp> |
| 50 | + #include <boost/filesystem/operations.hpp> |
| 51 | + #include <boost/filesystem/exception.hpp> |
| 52 | + #include <iostream> |
| 53 | +@@ -24,8 +25,7 @@ void bcp_implementation::add_path(const fs::path& p) |
| 54 | + { |
| 55 | + if (m_excluded.find(p) != m_excluded.end()) |
| 56 | + return; |
| 57 | +- fs::path normalized_path = p; |
| 58 | +- normalized_path.normalize(); |
| 59 | ++ fs::path normalized_path = p.lexically_normal(); |
| 60 | + if(fs::exists(m_boost_path / normalized_path)) |
| 61 | + { |
| 62 | + if(fs::is_directory(m_boost_path / normalized_path)) |
| 63 | +@@ -45,12 +45,12 @@ void bcp_implementation::add_directory(const fs::path& p) |
| 64 | + // |
| 65 | + // Don't add files created by build system: |
| 66 | + // |
| 67 | +- if((p.leaf() == "bin") || (p.leaf() == "bin-stage")) |
| 68 | ++ if((p.filename() == "bin") || (p.filename() == "bin-stage")) |
| 69 | + return; |
| 70 | + // |
| 71 | + // Don't add version control directories: |
| 72 | + // |
| 73 | +- if((p.leaf() == "CVS") || (p.leaf() == ".svn")) |
| 74 | ++ if((p.filename() == "CVS") || (p.filename() == ".svn")) |
| 75 | + return; |
| 76 | + // |
| 77 | + // don't add directories not under version control: |
| 78 | +@@ -180,7 +180,7 @@ void bcp_implementation::add_file(const fs::path& p) |
| 79 | + { |
| 80 | + // only concatonate if it's a relative path |
| 81 | + // rather than a URL: |
| 82 | +- fs::path dep(p.branch_path() / s); |
| 83 | ++ fs::path dep(p.parent_path() / s); |
| 84 | + if(!m_dependencies.count(dep)) |
| 85 | + { |
| 86 | + m_dependencies[dep] = p; // set up dependency tree |
| 87 | +@@ -355,13 +355,13 @@ void bcp_implementation::add_file_dependencies(const fs::path& p, bool scanfile) |
| 88 | + continue; |
| 89 | + } |
| 90 | + include_file = i->str(); |
| 91 | +- fs::path test_file(m_boost_path / p.branch_path() / include_file); |
| 92 | +- if(fs::exists(test_file) && !fs::is_directory(test_file) && (p.branch_path().string() != "boost")) |
| 93 | ++ fs::path test_file(m_boost_path / p.parent_path() / include_file); |
| 94 | ++ if(fs::exists(test_file) && !fs::is_directory(test_file) && (p.parent_path().string() != "boost")) |
| 95 | + { |
| 96 | +- if(!m_dependencies.count(p.branch_path() / include_file)) |
| 97 | ++ if(!m_dependencies.count(p.parent_path() / include_file)) |
| 98 | + { |
| 99 | +- m_dependencies[p.branch_path() / include_file] = p; |
| 100 | +- add_pending_path(p.branch_path() / include_file); |
| 101 | ++ m_dependencies[p.parent_path() / include_file] = p; |
| 102 | ++ add_pending_path(p.parent_path() / include_file); |
| 103 | + } |
| 104 | + } |
| 105 | + else if(fs::exists(m_boost_path / include_file)) |
| 106 | +@@ -405,13 +405,13 @@ void bcp_implementation::add_file_dependencies(const fs::path& p, bool scanfile) |
| 107 | + ++i; |
| 108 | + continue; |
| 109 | + } |
| 110 | +- fs::path test_file(m_boost_path / p.branch_path() / include_file); |
| 111 | +- if(fs::exists(test_file) && !fs::is_directory(test_file) && (p.branch_path().string() != "boost")) |
| 112 | ++ fs::path test_file(m_boost_path / p.parent_path() / include_file); |
| 113 | ++ if(fs::exists(test_file) && !fs::is_directory(test_file) && (p.parent_path().string() != "boost")) |
| 114 | + { |
| 115 | +- if(!m_dependencies.count(p.branch_path() / include_file)) |
| 116 | ++ if(!m_dependencies.count(p.parent_path() / include_file)) |
| 117 | + { |
| 118 | +- m_dependencies[p.branch_path() / include_file] = p; |
| 119 | +- add_pending_path(p.branch_path() / include_file); |
| 120 | ++ m_dependencies[p.parent_path() / include_file] = p; |
| 121 | ++ add_pending_path(p.parent_path() / include_file); |
| 122 | + } |
| 123 | + } |
| 124 | + else if(fs::exists(m_boost_path / include_file)) |
| 125 | +diff --git a/bcp_imp.hpp b/bcp_imp.hpp |
| 126 | +index e515581..51c85ba 100644 |
| 127 | +--- a/bcp_imp.hpp |
| 128 | ++++ b/bcp_imp.hpp |
| 129 | +@@ -14,6 +14,7 @@ |
| 130 | + #include <set> |
| 131 | + #include <map> |
| 132 | + #include <queue> |
| 133 | ++#include <string> |
| 134 | + #include <boost/filesystem/path.hpp> |
| 135 | + |
| 136 | + namespace fs = boost::filesystem; |
| 137 | +diff --git a/copy_path.cpp b/copy_path.cpp |
| 138 | +index 4143c79..6b7a370 100644 |
| 139 | +--- a/copy_path.cpp |
| 140 | ++++ b/copy_path.cpp |
| 141 | +@@ -49,18 +49,18 @@ void bcp_implementation::copy_path(const fs::path& p) |
| 142 | + if(fs::exists(m_dest_path / p)) |
| 143 | + { |
| 144 | + std::cout << "Copying (and overwriting) file: " << p.string() << "\n"; |
| 145 | +- fs::remove(m_dest_path / p); |
| 146 | ++ fs::remove(m_dest_path / p); |
| 147 | + } |
| 148 | + else |
| 149 | + std::cout << "Copying file: " << p.string() << "\n"; |
| 150 | + // |
| 151 | + // create the path to the new file if it doesn't already exist: |
| 152 | + // |
| 153 | +- create_path(p.branch_path()); |
| 154 | ++ create_path(p.parent_path()); |
| 155 | + // |
| 156 | + // do text based copy if requested: |
| 157 | + // |
| 158 | +- if((p.leaf() == "Jamroot") && m_namespace_name.size()) |
| 159 | ++ if((p.filename() == "Jamroot") && m_namespace_name.size()) |
| 160 | + { |
| 161 | + static std::vector<char> v1, v2; |
| 162 | + v1.clear(); |
| 163 | +@@ -240,7 +240,7 @@ void bcp_implementation::create_path(const fs::path& p) |
| 164 | + if(!fs::exists(m_dest_path / p)) |
| 165 | + { |
| 166 | + // recurse then create the path: |
| 167 | +- create_path(p.branch_path()); |
| 168 | ++ create_path(p.parent_path()); |
| 169 | + fs::create_directory(m_dest_path / p); |
| 170 | + } |
| 171 | + } |
| 172 | +diff --git a/file_types.cpp b/file_types.cpp |
| 173 | +index 297d304..69f6027 100644 |
| 174 | +--- a/file_types.cpp |
| 175 | ++++ b/file_types.cpp |
| 176 | +@@ -52,7 +52,7 @@ bool bcp_implementation::is_binary_file(const fs::path& p) |
| 177 | + "|" |
| 178 | + "(Jamfile|makefile|configure)", |
| 179 | + boost::regex::perl | boost::regex::icase); |
| 180 | +- return !boost::regex_match(p.leaf().generic_string(), e); |
| 181 | ++ return !boost::regex_match(p.filename().generic_string(), e); |
| 182 | + |
| 183 | + } |
| 184 | + |
0 commit comments