Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use std::filesystem instead of boost::filesystem #2153

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/actions/ubuntu-prerequisites/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ runs:
- name: Install software
run: |
sudo apt-get install -yq --no-install-suggests --no-install-recommends \
libboost-filesystem-dev \
libboost-system-dev \
libboost-dev \
libbz2-dev \
libexpat1-dev \
libopencv-dev \
Expand Down
2 changes: 0 additions & 2 deletions .github/actions/win-install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ runs:
- name: Install packages
run: |
vcpkg install \
boost-filesystem:x64-windows \
boost-geometry:x64-windows \
boost-property-tree:x64-windows \
boost-system:x64-windows \
bzip2:x64-windows \
expat:x64-windows \
libpq:x64-windows \
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/test-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ jobs:
sudo apt-get purge -yq postgresql*
sudo apt-get update -qq
sudo apt-get install -yq --no-install-suggests --no-install-recommends \
libboost-filesystem-dev \
libboost-system-dev \
libboost-dev \
libbz2-dev \
libexpat1-dev \
liblua${LUA_VERSION}-dev \
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ else()
message(STATUS "Building without Lua support")
endif()

find_package(Boost 1.50 REQUIRED COMPONENTS system filesystem)
find_package(Boost 1.50 REQUIRED)
include_directories(SYSTEM ${Boost_INCLUDE_DIR})

find_package(PostgreSQL REQUIRED)
Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ Required libraries are
* [proj](https://proj.org/)
* [bzip2](http://www.bzip.org/)
* [zlib](https://www.zlib.net/)
* [Boost libraries](https://www.boost.org/), including geometry, system and
filesystem
* [Boost libraries](https://www.boost.org/) (for boost geometry)
* [nlohmann/json](https://json.nlohmann.me/)
* [OpenCV](https://opencv.org/) (Optional, for generalization only)
* [potrace](https://potrace.sourceforge.net/) (Optional, for generalization only)
Expand All @@ -73,7 +72,7 @@ It also requires access to a database server running

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

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

```sh
sudo apt-get install make cmake g++ libboost-dev libboost-system-dev \
libboost-filesystem-dev libexpat1-dev zlib1g-dev libpotrace-dev \
sudo apt-get install make cmake g++ libboost-dev \
libexpat1-dev zlib1g-dev libpotrace-dev \
libopencv-dev libbz2-dev libpq-dev libproj-dev lua5.3 liblua5.3-dev \
pandoc nlohmann-json3-dev pyosmium
```
Expand Down
6 changes: 3 additions & 3 deletions src/lua-setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#include <lua.hpp>

#include <boost/filesystem.hpp>
#include <filesystem>

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

std::string dir_path =
boost::filesystem::path{filename}.parent_path().string();
std::filesystem::path{filename}.parent_path().string();
if (!dir_path.empty()) {
dir_path += boost::filesystem::path::preferred_separator;
dir_path += std::filesystem::path::preferred_separator;
}
luaX_add_table_str(lua_state, "config_dir", dir_path.c_str());

Expand Down
18 changes: 8 additions & 10 deletions src/osm2pgsql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@

#include <osmium/util/memory.hpp>

#include <boost/filesystem.hpp>

#include <exception>
#include <filesystem>
#include <memory>
#include <utility>

Expand Down Expand Up @@ -104,10 +103,9 @@ static void store_properties(properties_t *properties, options_t const &options)
properties->set_string("flat_node_file", "");
} else {
properties->set_string(
"flat_node_file",
boost::filesystem::absolute(
boost::filesystem::path{options.flat_node_file})
.string());
"flat_node_file", std::filesystem::absolute(
std::filesystem::path{options.flat_node_file})
.string());
}

properties->set_string("prefix", options.prefix);
Expand All @@ -121,7 +119,7 @@ static void store_properties(properties_t *properties, options_t const &options)
} else {
properties->set_string(
"style",
boost::filesystem::absolute(boost::filesystem::path{options.style})
std::filesystem::absolute(std::filesystem::path{options.style})
.string());
}

Expand Down Expand Up @@ -192,8 +190,8 @@ static void check_and_update_flat_node_file(properties_t *properties,
}
} else {
const auto absolute_path =
boost::filesystem::absolute(
boost::filesystem::path{options->flat_node_file})
std::filesystem::absolute(
std::filesystem::path{options->flat_node_file})
.string();

if (flat_node_file_from_import.empty()) {
Expand Down Expand Up @@ -288,7 +286,7 @@ static void check_and_update_style_file(properties_t *properties,
}

const auto absolute_path =
boost::filesystem::absolute(boost::filesystem::path{options->style})
std::filesystem::absolute(std::filesystem::path{options->style})
.string();

if (absolute_path == style_file_from_import) {
Expand Down
8 changes: 3 additions & 5 deletions tests/common-cleanup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@

#include "format.hpp"

#include <filesystem>
#include <string>

#include <boost/filesystem.hpp>

namespace testing::cleanup {

/**
Expand Down Expand Up @@ -44,9 +43,8 @@ class file_t
return;
}

boost::system::error_code ec;
boost::filesystem::remove(m_filename, ec);
if (ec && warn) {
std::error_code ec;
if (!std::filesystem::remove(m_filename, ec) && warn) {
fmt::print(stderr, "WARNING: Unable to remove \"{}\": {}\n",
m_filename, ec.message());
}
Expand Down