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

Switch to Boost::filesystem from standard C++ filesystem #186

Open
wants to merge 1 commit into
base: public
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ endif()

find_package(GMP REQUIRED)
find_package(Threads REQUIRED)
find_package(Boost 1.66.0 REQUIRED COMPONENTS thread system)
find_package(Boost 1.66.0 REQUIRED COMPONENTS filesystem thread system)

add_subdirectory(src/abycore)

Expand Down
9 changes: 1 addition & 8 deletions src/abycore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,8 @@ target_include_directories(aby
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
)

# This assumes that libstdc++ is used and should not be required for e.g.
# libc++. Linking to libstdc++fs is currently required when using the
# std::filesystem library.
# cf. https://gitlab.kitware.com/cmake/cmake/issues/17834
target_link_libraries(aby
PRIVATE stdc++fs
)

target_link_libraries(aby
PRIVATE Boost::filesystem
PUBLIC OTExtension::otextension
PUBLIC ENCRYPTO_utils::encrypto_utils
PUBLIC GMP::GMP
Expand Down
11 changes: 2 additions & 9 deletions src/abycore/sharing/boolsharing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,8 @@
#include "../aby/abysetup.h"
#include <cstdlib>

#if __has_include(<filesystem>)
#include <filesystem>
namespace filesystem = std::filesystem;
#elif __has_include(<experimental/filesystem>)
#include <experimental/filesystem>
namespace filesystem = std::experimental::filesystem;
#else
#error "C++17 filesystem library not found"
#endif
#include <boost/filesystem.hpp>
namespace filesystem = boost::filesystem;


void BoolSharing::Init() {
Expand Down
14 changes: 4 additions & 10 deletions src/abycore/sharing/sharing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,9 @@
#include <cstring>
#include <cstdlib>

#if __has_include(<filesystem>)
#include <filesystem>
namespace filesystem = std::filesystem;
#elif __has_include(<experimental/filesystem>)
#include <experimental/filesystem>
namespace filesystem = std::experimental::filesystem;
#else
#error "C++17 filesystem library not found"
#endif
#include <boost/system/error_code.hpp>
#include <boost/filesystem.hpp>
namespace filesystem = boost::filesystem;

#include <iostream>
#include <iomanip>
Expand Down Expand Up @@ -94,7 +88,7 @@ void Sharing::PreCompFileDelete() {
}
else {
truncation_size = filesystem::file_size(filename) - m_nFilePos;
std::error_code ec;
boost::system::error_code ec;
filesystem::resize_file(filename, truncation_size, ec);
if(ec) {
std::cout << "Error occured in truncate:" << ec.message() << std::endl;
Expand Down