From 406c0f46ca9d9a7785436a3981236aa0578c5b13 Mon Sep 17 00:00:00 2001
From: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
Date: Wed, 13 Sep 2023 12:10:23 -0300
Subject: [PATCH] build: fix filesystem::path to string conversion

Change-Id: I2c3a9f626ca56d63c239f2afc5d9ed71db6f631d
---
 src/connectionmanager.cpp  |  4 ++--
 src/fileutils.cpp          | 16 ++++++++--------
 src/security/certstore.cpp |  2 +-
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/connectionmanager.cpp b/src/connectionmanager.cpp
index dafd338..2b6e544 100644
--- a/src/connectionmanager.cpp
+++ b/src/connectionmanager.cpp
@@ -1345,9 +1345,9 @@ ConnectionManager::Impl::loadTreatedMessages()
 {
     std::lock_guard<std::mutex> lock(messageMutex_);
     auto path = config_->cachePath / "treatedMessages";
-    treatedMessages_ = loadIdList<std::string>(path);
+    treatedMessages_ = loadIdList<std::string>(path.string());
     if (treatedMessages_.empty()) {
-        auto messages = loadIdList(path);
+        auto messages = loadIdList(path.string());
         for (const auto& m : messages)
             treatedMessages_.emplace(to_hex_string(m));
     }
diff --git a/src/fileutils.cpp b/src/fileutils.cpp
index d4decab..95199e3 100644
--- a/src/fileutils.cpp
+++ b/src/fileutils.cpp
@@ -319,15 +319,15 @@ int
 remove(const std::filesystem::path& path, bool erase)
 {
     if (erase and isFile(path, false) and !hasHardLink(path))
-        eraseFile(path, true);
+        eraseFile(path.string(), true);
 
 #ifdef _WIN32
     // use Win32 api since std::remove will not unlink directory in use
     if (isDirectory(path))
-        return !RemoveDirectory(dhtnet::to_wstring(path).c_str());
+        return !RemoveDirectory(dhtnet::to_wstring(path.string()).c_str());
 #endif
 
-    return std::remove(path.c_str());
+    return std::remove(path.string().c_str());
 }
 
 int
@@ -350,7 +350,7 @@ void
 openStream(std::ifstream& file, const std::filesystem::path& path, std::ios_base::openmode mode)
 {
 #ifdef _WIN32
-    file.open(dhtnet::to_wstring(path), mode);
+    file.open(dhtnet::to_wstring(path.string()), mode);
 #else
     file.open(path, mode);
 #endif
@@ -360,7 +360,7 @@ void
 openStream(std::ofstream& file, const std::filesystem::path& path, std::ios_base::openmode mode)
 {
 #ifdef _WIN32
-    file.open(dhtnet::to_wstring(path), mode);
+    file.open(dhtnet::to_wstring(path.string()), mode);
 #else
     file.open(path, mode);
 #endif
@@ -370,7 +370,7 @@ std::ifstream
 ifstream(const std::filesystem::path& path, std::ios_base::openmode mode)
 {
 #ifdef _WIN32
-    return std::ifstream(dhtnet::to_wstring(path), mode);
+    return std::ifstream(dhtnet::to_wstring(path.string()), mode);
 #else
     return std::ifstream(path, mode);
 #endif
@@ -380,7 +380,7 @@ std::ofstream
 ofstream(const std::filesystem::path& path, std::ios_base::openmode mode)
 {
 #ifdef _WIN32
-    return std::ofstream(dhtnet::to_wstring(path), mode);
+    return std::ofstream(dhtnet::to_wstring(path.string()), mode);
 #else
     return std::ofstream(path, mode);
 #endif
@@ -390,7 +390,7 @@ int
 accessFile(const std::filesystem::path& file, int mode)
 {
 #ifdef _WIN32
-    return _waccess(dhtnet::to_wstring(file).c_str(), mode);
+    return _waccess(dhtnet::to_wstring(file.string()).c_str(), mode);
 #else
     return access(file.c_str(), mode);
 #endif
diff --git a/src/security/certstore.cpp b/src/security/certstore.cpp
index ee5b9d6..e58b288 100644
--- a/src/security/certstore.cpp
+++ b/src/security/certstore.cpp
@@ -279,7 +279,7 @@ CertificateStore::pinCertificatePath(const std::string& path,
                                      std::function<void(const std::vector<std::string>&)> cb)
 {
     dht::ThreadPool::computation().run([&, path, cb]() {
-        auto certs = readCertificates(path, crlPath_);
+        auto certs = readCertificates(path, crlPath_.string());
         std::vector<std::string> ids;
         std::vector<std::weak_ptr<crypto::Certificate>> scerts;
         ids.reserve(certs.size());
-- 
GitLab