Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Commit

Permalink
remove boost::filesystem dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
doug-moen committed Nov 21, 2021
1 parent ee5cd8b commit a1618ae
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 21 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ else ()
endif ()

# Boost library (Windows port required 1.72, 1.65 is latest for Ubuntu 18.04)
find_package(Boost 1.65 REQUIRED COMPONENTS iostreams filesystem system)
find_package(Boost 1.65 REQUIRED COMPONENTS iostreams system)

# imdemo, broken in v1.65 of ImGui, need to upgrade to headrev
#add_executable(imdemo
Expand Down Expand Up @@ -193,14 +193,14 @@ endif ()
set(Libs
libcurv_io libcurv imgui glfw glad ${LibOpenGL} replxx double-conversion
tmc ${FatLibraries}
Boost::iostreams Boost::filesystem Boost::system
Boost::iostreams Boost::system
pthread ${LibDl} ${LibOmp})

target_link_libraries(curv PUBLIC ${Libs})

file(GLOB TestSrc "tests/*.cc")
add_executable(tester EXCLUDE_FROM_ALL ${TestSrc})
target_link_libraries(tester PUBLIC gtest pthread libcurv libcurv_io double-conversion Boost::iostreams Boost::filesystem Boost::system)
target_link_libraries(tester PUBLIC gtest pthread libcurv libcurv_io double-conversion Boost::iostreams Boost::system)

set_property(TARGET curv libcurv libcurv_io tester PROPERTY CXX_STANDARD 17)

Expand Down
2 changes: 1 addition & 1 deletion curv/curv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ make_system(const char* argv0, std::list<const char*>& libs, std::ostream& out,
curv::io::add_importers(sys);
if (argv0 != nullptr) {
const char* CURV_LIBDIR = getenv("CURV_LIBDIR");
namespace fs = boost::filesystem;
namespace fs = std::filesystem;
curv::Shared<const curv::String> stdlib;
if (CURV_LIBDIR != nullptr) {
if (CURV_LIBDIR[0] != '\0') {
Expand Down
4 changes: 2 additions & 2 deletions libcurv/builtin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
#include <libcurv/system.h>

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

#include <cassert>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <filesystem>
#include <string>

using namespace std;
Expand Down Expand Up @@ -1086,7 +1086,7 @@ struct File_Expr : public Just_Expression
// construct file pathname from argument
Value arg = arg_->eval(fm);
auto argstr = value_to_string(arg, Fail::hard, cx);
namespace fs = boost::filesystem;
namespace fs = std::filesystem;
fs::path filepath;
auto caller_filename = syntax_->location().source().name_;
if (caller_filename->empty()) {
Expand Down
6 changes: 3 additions & 3 deletions libcurv/dir_record.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ Dir_Record::Dir_Record(Filesystem::path dir, const Context& cx)
dir_(dir),
fields_{}
{
namespace fs = boost::filesystem;
namespace fs = std::filesystem;
System& sys(cx.system());

fs::directory_iterator i(dir);
fs::directory_iterator end;
for (; i != end; ++i) {
auto path = i->path();
auto name = path.leaf().string();
auto name = path.filename().string();
auto cname = name.c_str();
if (cname[0] == '.') continue;

Expand All @@ -53,7 +53,7 @@ Dir_Record::Dir_Record(Filesystem::path dir, const Context& cx)
if (ext.empty()) {
// If a filename has no extension, it is statted to test if it is
// a directory. If yes, it is imported, otherwise it is ignored.
boost::system::error_code errcode;
std::error_code errcode;
if (fs::is_directory(path, errcode))
fields_[make_symbol(cname)] = File{dir_import, path, missing};
else if (errcode)
Expand Down
5 changes: 2 additions & 3 deletions libcurv/filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
#ifndef LIBCURV_FILESYSTEM_H
#define LIBCURV_FILESYSTEM_H

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

namespace curv {

// Once we migrate to C++17, we'll use std::filesystem instead.
namespace Filesystem = boost::filesystem;
namespace Filesystem = std::filesystem;

struct Path_Hash
{
Expand Down
4 changes: 2 additions & 2 deletions libcurv/import.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void import(const Filesystem::path& path, Program& prog, const Context& cx)
System& sys{cx.system()};

// If file is a directory, use directory import.
boost::system::error_code errcode;
std::error_code errcode;
if (Filesystem::is_directory(path, errcode))
return dir_import(path, prog, cx);
if (errcode)
Expand All @@ -42,7 +42,7 @@ void import(const Filesystem::path& path, Program& prog, const Context& cx)
Value
import_value(Importer imp, const Filesystem::path& path, const Context& cx)
{
boost::system::error_code errcode;
std::error_code errcode;
auto filekey = Filesystem::canonical(path, errcode);
if (errcode)
throw Exception(cx, stringify(path,": ",errcode.message()));
Expand Down
2 changes: 1 addition & 1 deletion libcurv/io/tempfile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ remove_all_tempfiles()
{
for (auto& file : tempfiles)
{
boost::system::error_code error;
std::error_code error;
fs::remove(file, error);
if (error)
{
Expand Down
6 changes: 3 additions & 3 deletions libcurv/output_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <libcurv/output_file.h>
#include <libcurv/context.h>
#include <libcurv/exception.h>
#include <boost/filesystem.hpp>

#ifdef _WIN32
#include <libcurv/win32.h>
Expand All @@ -22,8 +21,9 @@ extern "C" {
#endif
}

#include <iostream>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <string>

namespace curv {
Expand Down Expand Up @@ -129,7 +129,7 @@ Output_File::commit()

Output_File::~Output_File()
{
boost::system::error_code error;
std::error_code error;
fs::remove(tempfile_path_, error);
if (error)
{
Expand Down
2 changes: 1 addition & 1 deletion libcurv/progdir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ extern "C" {
}
#include <libcurv/exception.h>
#include <libcurv/progdir.h>
namespace fs = boost::filesystem;
namespace fs = std::filesystem;

namespace curv {

Expand Down
4 changes: 2 additions & 2 deletions libcurv/progdir.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
#ifndef LIBCURV_PROGDIR_H
#define LIBCURV_PROGDIR_H

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

namespace curv {

boost::filesystem::path progdir(const char* argv0);
std::filesystem::path progdir(const char* argv0);

}
#endif // header guard

0 comments on commit a1618ae

Please sign in to comment.