Skip to content

Commit 6466532

Browse files
authored
Merge pull request #2153 from joto/replace-boost-filesystem-by-std-filesystem
Use std::filesystem instead of boost::filesystem
2 parents 06f3ed5 + 3bd217d commit 6466532

File tree

8 files changed

+21
-30
lines changed

8 files changed

+21
-30
lines changed

.github/actions/ubuntu-prerequisites/action.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ runs:
1616
- name: Install software
1717
run: |
1818
sudo apt-get install -yq --no-install-suggests --no-install-recommends \
19-
libboost-filesystem-dev \
20-
libboost-system-dev \
19+
libboost-dev \
2120
libbz2-dev \
2221
libexpat1-dev \
2322
libopencv-dev \

.github/actions/win-install/action.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ runs:
77
- name: Install packages
88
run: |
99
vcpkg install \
10-
boost-filesystem:x64-windows \
1110
boost-geometry:x64-windows \
1211
boost-property-tree:x64-windows \
13-
boost-system:x64-windows \
1412
bzip2:x64-windows \
1513
expat:x64-windows \
1614
libpq:x64-windows \

.github/workflows/test-install.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ jobs:
3838
sudo apt-get purge -yq postgresql*
3939
sudo apt-get update -qq
4040
sudo apt-get install -yq --no-install-suggests --no-install-recommends \
41-
libboost-filesystem-dev \
42-
libboost-system-dev \
41+
libboost-dev \
4342
libbz2-dev \
4443
libexpat1-dev \
4544
liblua${LUA_VERSION}-dev \

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ else()
202202
message(STATUS "Building without Lua support")
203203
endif()
204204

205-
find_package(Boost 1.50 REQUIRED COMPONENTS system filesystem)
205+
find_package(Boost 1.50 REQUIRED)
206206
include_directories(SYSTEM ${Boost_INCLUDE_DIR})
207207

208208
find_package(PostgreSQL REQUIRED)

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ Required libraries are
4848
* [proj](https://proj.org/)
4949
* [bzip2](http://www.bzip.org/)
5050
* [zlib](https://www.zlib.net/)
51-
* [Boost libraries](https://www.boost.org/), including geometry, system and
52-
filesystem
51+
* [Boost libraries](https://www.boost.org/) (for boost geometry)
5352
* [nlohmann/json](https://json.nlohmann.me/)
5453
* [OpenCV](https://opencv.org/) (Optional, for generalization only)
5554
* [potrace](https://potrace.sourceforge.net/) (Optional, for generalization only)
@@ -73,7 +72,7 @@ It also requires access to a database server running
7372

7473
Make sure you have installed the development packages for the libraries
7574
mentioned in the requirements section and a C++ compiler which supports C++17.
76-
We officially support gcc >= 7.0 and clang >= 8.
75+
We officially support gcc >= 8.0 and clang >= 8.
7776

7877
To rebuild the included man page you'll need the [pandoc](https://pandoc.org/)
7978
tool.
@@ -83,8 +82,8 @@ First install the dependencies.
8382
On a Debian or Ubuntu system, this can be done with:
8483

8584
```sh
86-
sudo apt-get install make cmake g++ libboost-dev libboost-system-dev \
87-
libboost-filesystem-dev libexpat1-dev zlib1g-dev libpotrace-dev \
85+
sudo apt-get install make cmake g++ libboost-dev \
86+
libexpat1-dev zlib1g-dev libpotrace-dev \
8887
libopencv-dev libbz2-dev libpq-dev libproj-dev lua5.3 liblua5.3-dev \
8988
pandoc nlohmann-json3-dev pyosmium
9089
```

src/lua-setup.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#include <lua.hpp>
1515

16-
#include <boost/filesystem.hpp>
16+
#include <filesystem>
1717

1818
void setup_lua_environment(lua_State *lua_state, std::string const &filename,
1919
bool append_mode)
@@ -29,9 +29,9 @@ void setup_lua_environment(lua_State *lua_state, std::string const &filename,
2929
luaX_add_table_str(lua_state, "version", get_osm2pgsql_short_version());
3030

3131
std::string dir_path =
32-
boost::filesystem::path{filename}.parent_path().string();
32+
std::filesystem::path{filename}.parent_path().string();
3333
if (!dir_path.empty()) {
34-
dir_path += boost::filesystem::path::preferred_separator;
34+
dir_path += std::filesystem::path::preferred_separator;
3535
}
3636
luaX_add_table_str(lua_state, "config_dir", dir_path.c_str());
3737

src/osm2pgsql.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@
2424

2525
#include <osmium/util/memory.hpp>
2626

27-
#include <boost/filesystem.hpp>
28-
2927
#include <exception>
28+
#include <filesystem>
3029
#include <memory>
3130
#include <utility>
3231

@@ -104,10 +103,9 @@ static void store_properties(properties_t *properties, options_t const &options)
104103
properties->set_string("flat_node_file", "");
105104
} else {
106105
properties->set_string(
107-
"flat_node_file",
108-
boost::filesystem::absolute(
109-
boost::filesystem::path{options.flat_node_file})
110-
.string());
106+
"flat_node_file", std::filesystem::absolute(
107+
std::filesystem::path{options.flat_node_file})
108+
.string());
111109
}
112110

113111
properties->set_string("prefix", options.prefix);
@@ -121,7 +119,7 @@ static void store_properties(properties_t *properties, options_t const &options)
121119
} else {
122120
properties->set_string(
123121
"style",
124-
boost::filesystem::absolute(boost::filesystem::path{options.style})
122+
std::filesystem::absolute(std::filesystem::path{options.style})
125123
.string());
126124
}
127125

@@ -192,8 +190,8 @@ static void check_and_update_flat_node_file(properties_t *properties,
192190
}
193191
} else {
194192
const auto absolute_path =
195-
boost::filesystem::absolute(
196-
boost::filesystem::path{options->flat_node_file})
193+
std::filesystem::absolute(
194+
std::filesystem::path{options->flat_node_file})
197195
.string();
198196

199197
if (flat_node_file_from_import.empty()) {
@@ -288,7 +286,7 @@ static void check_and_update_style_file(properties_t *properties,
288286
}
289287

290288
const auto absolute_path =
291-
boost::filesystem::absolute(boost::filesystem::path{options->style})
289+
std::filesystem::absolute(std::filesystem::path{options->style})
292290
.string();
293291

294292
if (absolute_path == style_file_from_import) {

tests/common-cleanup.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212

1313
#include "format.hpp"
1414

15+
#include <filesystem>
1516
#include <string>
1617

17-
#include <boost/filesystem.hpp>
18-
1918
namespace testing::cleanup {
2019

2120
/**
@@ -44,9 +43,8 @@ class file_t
4443
return;
4544
}
4645

47-
boost::system::error_code ec;
48-
boost::filesystem::remove(m_filename, ec);
49-
if (ec && warn) {
46+
std::error_code ec;
47+
if (!std::filesystem::remove(m_filename, ec) && warn) {
5048
fmt::print(stderr, "WARNING: Unable to remove \"{}\": {}\n",
5149
m_filename, ec.message());
5250
}

0 commit comments

Comments
 (0)