summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan.goodliffe@octal.co.uk>2019-01-29 14:05:56 +0000
committerDan Goodliffe <dan.goodliffe@octal.co.uk>2019-01-29 14:21:24 +0000
commite6c80195e9019a355d9a7a40b61bcf099d9a72a0 (patch)
tree693e9645c8e0d735be1b1685fba73e0fc7a0db88
parentAdd missing doxygen comments (diff)
downloadlibadhocutil-e6c80195e9019a355d9a7a40b61bcf099d9a72a0.tar.bz2
libadhocutil-e6c80195e9019a355d9a7a40b61bcf099d9a72a0.tar.xz
libadhocutil-e6c80195e9019a355d9a7a40b61bcf099d9a72a0.zip
Remove boost::filesystem in favour of std::filesystem
-rw-r--r--libadhocutil/Jamfile.jam8
-rw-r--r--libadhocutil/definedDirs.h9
-rw-r--r--libadhocutil/fileUtils.cpp27
-rw-r--r--libadhocutil/fileUtils.h20
-rw-r--r--libadhocutil/fprintbf.cpp2
-rw-r--r--libadhocutil/fprintbf.h4
-rw-r--r--libadhocutil/unittests/Jamfile.jam35
-rw-r--r--libadhocutil/unittests/testCompileTimeFormatter.cpp4
-rw-r--r--libadhocutil/unittests/testDirs.cpp12
-rw-r--r--libadhocutil/unittests/testFileUtils.cpp7
-rw-r--r--libadhocutil/unittests/testPluginsRuntime.cpp4
-rw-r--r--libadhocutil/unittests/testProcessPipes.cpp2
-rw-r--r--libadhocutil/uriParse.h4
13 files changed, 59 insertions, 79 deletions
diff --git a/libadhocutil/Jamfile.jam b/libadhocutil/Jamfile.jam
index 15d253a..715874c 100644
--- a/libadhocutil/Jamfile.jam
+++ b/libadhocutil/Jamfile.jam
@@ -1,9 +1,7 @@
import package ;
import lex ;
-lib boost_system ;
-lib boost_filesystem ;
-lib boost_thread ;
+lib stdc++fs ;
lib Ice++11 : ;
lib pthread ;
lib curl ;
@@ -14,9 +12,7 @@ lib adhocutil :
:
<include>.
<library>Ice++11
- <library>boost_system
- <library>boost_filesystem
- <library>boost_thread
+ <library>stdc++fs
<library>curl
<library>..//glibmm
<library>dl
diff --git a/libadhocutil/definedDirs.h b/libadhocutil/definedDirs.h
index d3e6507..accb663 100644
--- a/libadhocutil/definedDirs.h
+++ b/libadhocutil/definedDirs.h
@@ -1,8 +1,7 @@
#ifndef ADHOCUTIL_DEFINEDDIRS_H
#define ADHOCUTIL_DEFINEDDIRS_H
-#include <boost/filesystem/path.hpp>
-#include <boost/filesystem/convenience.hpp>
+#include <filesystem>
#ifndef ROOT
#error "ROOT needs to be defined at compilation time"
@@ -10,9 +9,9 @@
#define XSTR(s) STR(s)
#define STR(s) #s
-const boost::filesystem::path selfExe = boost::filesystem::canonical("/proc/self/exe");
-const boost::filesystem::path binDir = selfExe.parent_path();
-const boost::filesystem::path rootDir(XSTR(ROOT));
+const std::filesystem::path selfExe = std::filesystem::canonical("/proc/self/exe");
+const std::filesystem::path binDir = selfExe.parent_path();
+const std::filesystem::path rootDir(XSTR(ROOT));
#endif
diff --git a/libadhocutil/fileUtils.cpp b/libadhocutil/fileUtils.cpp
index 6cfce68..76d57a8 100644
--- a/libadhocutil/fileUtils.cpp
+++ b/libadhocutil/fileUtils.cpp
@@ -3,12 +3,13 @@
#include <unistd.h>
#include <sys.h>
#include <sys/mman.h>
+#include <boost/assert.hpp>
namespace AdHoc {
namespace FileUtils {
AdHocFormatter(FD, "FD %?");
- boost::filesystem::path operator/(const boost::filesystem::path & p, unsigned int n)
+ std::filesystem::path operator/(const std::filesystem::path & p, unsigned int n)
{
auto pp = p.begin();
while (n--) ++pp;
@@ -26,19 +27,19 @@ namespace AdHoc {
const_cast<int &>(o.fh) = -1;
}
- FileHandle::FileHandle(const boost::filesystem::path & path, int flags) :
+ FileHandle::FileHandle(const std::filesystem::path & path, int flags) :
fh(open(path.c_str(), flags))
{
if (fh < 0) {
- throw SystemExceptionOn("open(2) failed", strerror(errno), errno, path.string());
+ throw SystemExceptionOn("open(2) failed", strerror(errno), errno, path);
}
}
- FileHandle::FileHandle(const boost::filesystem::path & path, int flags, int mode) :
+ FileHandle::FileHandle(const std::filesystem::path & path, int flags, int mode) :
fh(open(path.c_str(), flags, mode))
{
if (fh < 0) {
- throw SystemExceptionOn("open(2) failed", strerror(errno), errno, path.string());
+ throw SystemExceptionOn("open(2) failed", strerror(errno), errno, path);
}
}
@@ -60,13 +61,13 @@ namespace AdHoc {
refreshStat();
}
- FileHandleStat::FileHandleStat(const boost::filesystem::path & path, int flags) :
+ FileHandleStat::FileHandleStat(const std::filesystem::path & path, int flags) :
FileHandle(path, flags)
{
refreshStat(path);
}
- FileHandleStat::FileHandleStat(const boost::filesystem::path & path, int flags, int mode) :
+ FileHandleStat::FileHandleStat(const std::filesystem::path & path, int flags, int mode) :
FileHandle(path, flags, mode)
{
refreshStat(path);
@@ -90,11 +91,11 @@ namespace AdHoc {
}
void
- FileHandleStat::refreshStat(const boost::filesystem::path & path)
+ FileHandleStat::refreshStat(const std::filesystem::path & path)
{
if (fstat(fh, &st)) {
// LCOV_EXCL_START can't think of a way to test open succeeding and fstat failing
- throw SystemExceptionOn("fstat(2) failed", strerror(errno), errno, path.string());
+ throw SystemExceptionOn("fstat(2) failed", strerror(errno), errno, path);
// LCOV_EXCL_STOP
}
}
@@ -105,13 +106,13 @@ namespace AdHoc {
{
}
- MemMap::MemMap(const boost::filesystem::path & path, int flags) :
+ MemMap::MemMap(const std::filesystem::path & path, int flags) :
FileHandleStat(path, flags),
data(setupMap(path, flags))
{
}
- MemMap::MemMap(const boost::filesystem::path & path, int flags, int mode) :
+ MemMap::MemMap(const std::filesystem::path & path, int flags, int mode) :
FileHandleStat(path, flags, mode),
data(setupMap(path, flags))
{
@@ -139,11 +140,11 @@ namespace AdHoc {
}
void *
- MemMap::setupMap(const boost::filesystem::path & path, int flags) const
+ MemMap::setupMap(const std::filesystem::path & path, int flags) const
{
auto data = setupMapInt(flags);
if (data == (void*)-1) {
- throw SystemExceptionOn("mmap(2) failed", strerror(errno), errno, path.string());
+ throw SystemExceptionOn("mmap(2) failed", strerror(errno), errno, path);
}
return data;
}
diff --git a/libadhocutil/fileUtils.h b/libadhocutil/fileUtils.h
index f272ddd..139dbb5 100644
--- a/libadhocutil/fileUtils.h
+++ b/libadhocutil/fileUtils.h
@@ -1,7 +1,7 @@
#ifndef ADHOCUTIL_FILEUTILS_H
#define ADHOCUTIL_FILEUTILS_H
-#include <boost/filesystem/path.hpp>
+#include <filesystem>
#include <sys/stat.h>
#include <fcntl.h>
#include <string_view>
@@ -15,7 +15,7 @@ namespace AdHoc {
* @param n The index of the element to extract.
* @return The path element.
*/
- DLL_PUBLIC boost::filesystem::path operator/(const boost::filesystem::path & p, unsigned int n);
+ DLL_PUBLIC std::filesystem::path operator/(const std::filesystem::path & p, unsigned int n);
/**
* File handle wrapper to ensure closure on scope exit
@@ -38,7 +38,7 @@ namespace AdHoc {
* @param path Path of file to open.
* @param flags File handle flags
*/
- FileHandle(const boost::filesystem::path & path, int flags = O_RDONLY);
+ FileHandle(const std::filesystem::path & path, int flags = O_RDONLY);
/**
* Open a new file handle.
@@ -46,7 +46,7 @@ namespace AdHoc {
* @param flags File handle flags
* @param mode File handle mode
*/
- FileHandle(const boost::filesystem::path & path, int flags, int mode);
+ FileHandle(const std::filesystem::path & path, int flags, int mode);
virtual ~FileHandle();
@@ -84,7 +84,7 @@ namespace AdHoc {
* @param path Path of file to open.
* @param flags File handle flags
*/
- FileHandleStat(const boost::filesystem::path & path, int flags = O_RDONLY);
+ FileHandleStat(const std::filesystem::path & path, int flags = O_RDONLY);
/**
* Open a new file handle.
@@ -92,7 +92,7 @@ namespace AdHoc {
* @param flags File handle flags
* @param mode File handle mode
*/
- FileHandleStat(const boost::filesystem::path & path, int flags, int mode);
+ FileHandleStat(const std::filesystem::path & path, int flags, int mode);
/**
* Get the stat structure.
@@ -111,7 +111,7 @@ namespace AdHoc {
struct stat st;
private:
- DLL_PRIVATE void refreshStat(const boost::filesystem::path & path);
+ DLL_PRIVATE void refreshStat(const std::filesystem::path & path);
};
/**
@@ -136,7 +136,7 @@ namespace AdHoc {
* @param path Path of file to open.
* @param flags File handle flags
*/
- MemMap(const boost::filesystem::path & path, int flags = O_RDONLY);
+ MemMap(const std::filesystem::path & path, int flags = O_RDONLY);
/**
* Open a new file handle.
@@ -144,7 +144,7 @@ namespace AdHoc {
* @param flags File handle flags
* @param mode File handle mode
*/
- MemMap(const boost::filesystem::path & path, int flags, int mode);
+ MemMap(const std::filesystem::path & path, int flags, int mode);
~MemMap();
@@ -165,7 +165,7 @@ namespace AdHoc {
private:
DLL_PUBLIC void * setupMapInt(int flags) const;
DLL_PUBLIC void * setupMap(int flags) const;
- DLL_PUBLIC void * setupMap(const boost::filesystem::path & path, int flags) const;
+ DLL_PUBLIC void * setupMap(const std::filesystem::path & path, int flags) const;
};
}
}
diff --git a/libadhocutil/fprintbf.cpp b/libadhocutil/fprintbf.cpp
index a80e571..b62ebf0 100644
--- a/libadhocutil/fprintbf.cpp
+++ b/libadhocutil/fprintbf.cpp
@@ -23,7 +23,7 @@ fprintbf(FILE * f, const boost::format & fmt)
}
FILE *
-fopen(const boost::filesystem::path & path, const char * mode)
+fopen(const std::filesystem::path & path, const char * mode)
{
auto f = fopen(path.c_str(), mode);
if (!f) {
diff --git a/libadhocutil/fprintbf.h b/libadhocutil/fprintbf.h
index e3c16a7..15366d2 100644
--- a/libadhocutil/fprintbf.h
+++ b/libadhocutil/fprintbf.h
@@ -4,13 +4,13 @@
#include "visibility.h"
#include "buffer.h"
#include <boost/format.hpp>
-#include <boost/filesystem/path.hpp>
+#include <filesystem>
DLL_PUBLIC size_t fprintss(FILE *, const std::string &);
DLL_PUBLIC size_t fprintbf(FILE *, const boost::format &);
-DLL_PUBLIC FILE * fopen(const boost::filesystem::path & path, const char * mode);
+DLL_PUBLIC FILE * fopen(const std::filesystem::path & path, const char * mode);
template <typename ... Params>
size_t inline fprintbf(FILE * f, const std::string & fmt, const Params & ... p)
diff --git a/libadhocutil/unittests/Jamfile.jam b/libadhocutil/unittests/Jamfile.jam
index fbf92b4..02a9275 100644
--- a/libadhocutil/unittests/Jamfile.jam
+++ b/libadhocutil/unittests/Jamfile.jam
@@ -15,9 +15,7 @@ actions xxd.h
IMPORT $(__name__) : xxd.h : : xxd.h ;
lib boost_utf : : <name>boost_unit_test_framework ;
-lib boost_filesystem ;
-lib boost_system ;
-lib boost_thread ;
+lib stdc++fs ;
lib pthread ;
lib dl ;
@@ -29,8 +27,7 @@ run
<define>ROOT=\"$(me)\"
<define>BOOST_TEST_DYN_LINK
<library>..//adhocutil
- <library>boost_system
- <library>boost_filesystem
+ <library>stdc++fs
<library>boost_utf
<implicit-dependency>lorem-ipsum
;
@@ -41,8 +38,7 @@ run
<define>ROOT=\"$(me)\"
<define>BOOST_TEST_DYN_LINK
<library>..//adhocutil
- <library>boost_system
- <library>boost_filesystem
+ <library>stdc++fs
<library>boost_utf
:
testUriParse
@@ -66,8 +62,7 @@ run
<define>BOOST_TEST_DYN_LINK
<library>..//adhocutil
<library>boost_utf
- <library>boost_filesystem
- <library>boost_system
+ <library>stdc++fs
<implicit-dependency>..//adhocutil
:
testCurl
@@ -90,8 +85,7 @@ run
<define>ROOT=\"$(me)\"
<library>..//adhocutil
<library>boost_utf
- <library>boost_filesystem
- <library>boost_system
+ <library>stdc++fs
:
testProcessPipes
;
@@ -122,7 +116,6 @@ run
<define>BOOST_TEST_DYN_LINK
<library>..//adhocutil
<library>boost_utf
- <library>boost_system
<library>pthread
:
testLocks
@@ -154,7 +147,6 @@ run
<define>BOOST_TEST_DYN_LINK
<library>..//adhocutil
<library>boost_utf
- <library>boost_system
<library>pthread
:
testCache
@@ -177,8 +169,7 @@ run
<library>..//adhocutil
<library>boost_utf
<define>ROOT=\"$(me)\"
- <library>boost_filesystem
- <library>boost_system
+ <library>stdc++fs
:
testDirs
;
@@ -201,8 +192,7 @@ run
<define>BOOST_TEST_DYN_LINK
<library>..//adhocutil
<library>boost_utf
- <library>boost_filesystem
- <library>boost_system
+ <library>stdc++fs
<library>dl
<dependency>utilTestClasses
:
@@ -225,7 +215,6 @@ run
<define>BOOST_TEST_DYN_LINK
<library>..//adhocutil
<library>boost_utf
- <library>boost_system
<library>pthread
:
testSemaphore
@@ -247,7 +236,6 @@ run
<define>BOOST_TEST_DYN_LINK
<library>..//adhocutil
<library>boost_utf
- <library>boost_system
<library>pthread
:
testResourcePool
@@ -260,8 +248,7 @@ run
<library>..//adhocutil
<library>boost_utf
<define>ROOT=\"$(me)\"
- <library>boost_system
- <library>boost_filesystem
+ <library>stdc++fs
:
testFprintbf
;
@@ -274,8 +261,7 @@ run
<implicit-dependency>..//adhocutil
<library>boost_utf
<define>ROOT=\"$(me)\"
- <library>boost_system
- <library>boost_filesystem
+ <library>stdc++fs
;
run
@@ -285,8 +271,7 @@ run
<library>..//adhocutil
<library>boost_utf
<define>ROOT=\"$(me)\"
- <library>boost_system
- <library>boost_filesystem
+ <library>stdc++fs
;
run
diff --git a/libadhocutil/unittests/testCompileTimeFormatter.cpp b/libadhocutil/unittests/testCompileTimeFormatter.cpp
index 65fbaa0..b02eadd 100644
--- a/libadhocutil/unittests/testCompileTimeFormatter.cpp
+++ b/libadhocutil/unittests/testCompileTimeFormatter.cpp
@@ -5,7 +5,7 @@
#include <fileUtils.h>
#include <definedDirs.h>
-#include <boost/filesystem/path.hpp>
+#include <filesystem>
using namespace AdHoc;
@@ -169,7 +169,7 @@ BOOST_AUTO_TEST_CASE ( singleDouble )
BOOST_AUTO_TEST_CASE ( singlePath )
{
- boost::filesystem::path p("/tmp/test/path");
+ std::filesystem::path p("/tmp/test/path");
Formatter<formatStringSingle>::write(*this, p);
BOOST_CHECK_EQUAL(this->str(), R"(single "/tmp/test/path".)");
}
diff --git a/libadhocutil/unittests/testDirs.cpp b/libadhocutil/unittests/testDirs.cpp
index 4e07f94..5a6065e 100644
--- a/libadhocutil/unittests/testDirs.cpp
+++ b/libadhocutil/unittests/testDirs.cpp
@@ -2,15 +2,15 @@
#include <boost/test/unit_test.hpp>
#include <definedDirs.h>
-#include <boost/filesystem/convenience.hpp>
+#include <filesystem>
BOOST_AUTO_TEST_CASE( iexist )
{
- BOOST_REQUIRE(boost::filesystem::exists(selfExe));
+ BOOST_REQUIRE(std::filesystem::exists(selfExe));
BOOST_REQUIRE(selfExe.is_absolute());
- BOOST_REQUIRE_EQUAL("testDirs", selfExe.leaf().string());
- BOOST_REQUIRE_EQUAL("unittests", rootDir.leaf().string());
- BOOST_REQUIRE(boost::filesystem::is_directory(binDir));
- BOOST_REQUIRE_EQUAL("libadhocutil", rootDir.parent_path().leaf().string());
+ BOOST_REQUIRE_EQUAL("testDirs", selfExe.filename().string());
+ BOOST_REQUIRE_EQUAL("unittests", rootDir.filename().string());
+ BOOST_REQUIRE(std::filesystem::is_directory(binDir));
+ BOOST_REQUIRE_EQUAL("libadhocutil", rootDir.parent_path().filename().string());
}
diff --git a/libadhocutil/unittests/testFileUtils.cpp b/libadhocutil/unittests/testFileUtils.cpp
index 01f1738..0dd61a7 100644
--- a/libadhocutil/unittests/testFileUtils.cpp
+++ b/libadhocutil/unittests/testFileUtils.cpp
@@ -116,12 +116,12 @@ BOOST_AUTO_TEST_CASE( memmap )
BOOST_AUTO_TEST_CASE( openmode )
{
- boost::filesystem::remove(binDir / "test.file");
+ std::filesystem::remove(binDir / "test.file");
BOOST_REQUIRE_THROW({
AdHoc::FileUtils::FileHandle fh(binDir / "test.file", O_RDONLY, S_IRWXU);
}, AdHoc::SystemExceptionOn);
AdHoc::FileUtils::FileHandle fh(binDir / "test.file", O_CREAT, S_IRWXU);
- boost::filesystem::remove(binDir / "test.file");
+ std::filesystem::remove(binDir / "test.file");
}
BOOST_AUTO_TEST_CASE( openfail )
@@ -159,12 +159,11 @@ BOOST_AUTO_TEST_CASE( msgOn )
BOOST_AUTO_TEST_CASE( pathPart )
{
using namespace AdHoc::FileUtils;
- boost::filesystem::path p("/this/is/some/path");
+ std::filesystem::path p("/this/is/some/path");
BOOST_REQUIRE_EQUAL(p / 0, "/");
BOOST_REQUIRE_EQUAL(p / 1, "this");
BOOST_REQUIRE_EQUAL(p / 2, "is");
BOOST_REQUIRE_EQUAL(p / 3, "some");
BOOST_REQUIRE_EQUAL(p / 4, "path");
- BOOST_REQUIRE_EQUAL(p / 5, "");
}
diff --git a/libadhocutil/unittests/testPluginsRuntime.cpp b/libadhocutil/unittests/testPluginsRuntime.cpp
index cfcc977..c68c39e 100644
--- a/libadhocutil/unittests/testPluginsRuntime.cpp
+++ b/libadhocutil/unittests/testPluginsRuntime.cpp
@@ -9,7 +9,7 @@
using namespace AdHoc;
-boost::filesystem::path lib;
+std::filesystem::path lib;
struct GetLibPath {
GetLibPath()
{
@@ -26,7 +26,7 @@ static std::optional<std::string> goodResolver(const std::type_info &, const std
BOOST_AUTO_TEST_CASE( ready )
{
BOOST_REQUIRE(PluginManager::getDefault());
- BOOST_REQUIRE(boost::filesystem::exists(lib));
+ BOOST_REQUIRE(std::filesystem::exists(lib));
}
BOOST_AUTO_TEST_CASE( clean )
diff --git a/libadhocutil/unittests/testProcessPipes.cpp b/libadhocutil/unittests/testProcessPipes.cpp
index 8a3a12e..f618940 100644
--- a/libadhocutil/unittests/testProcessPipes.cpp
+++ b/libadhocutil/unittests/testProcessPipes.cpp
@@ -9,7 +9,7 @@ using namespace AdHoc::System;
BOOST_AUTO_TEST_CASE ( readfind )
{
- ProcessPipes pp({"/usr/bin/find", rootDir.string(), "-maxdepth", "1"}, false, true, true);
+ ProcessPipes pp({"/usr/bin/find", rootDir, "-maxdepth", "1"}, false, true, true);
BOOST_REQUIRE_EQUAL(pp.fdIn(), -1);
BOOST_REQUIRE_NE(pp.fdOut(), -1);
BOOST_REQUIRE_NE(pp.fdError(), -1);
diff --git a/libadhocutil/uriParse.h b/libadhocutil/uriParse.h
index 0d8e302..72c1a4c 100644
--- a/libadhocutil/uriParse.h
+++ b/libadhocutil/uriParse.h
@@ -4,7 +4,7 @@
#include "visibility.h"
#include "exception.h"
#include <optional>
-#include <boost/filesystem/path.hpp>
+#include <filesystem>
#include <string>
#include <map>
@@ -29,7 +29,7 @@ namespace AdHoc {
/// The optional port.
std::optional<uint16_t> port;
/// The optional path.
- std::optional<boost::filesystem::path> path;
+ std::optional<std::filesystem::path> path;
/// The parsed components of the query string.
std::multimap<std::string, std::string> query;
/// The optional fragment.