diff --git a/include/fileutils.h b/include/fileutils.h index 7b1cc725747f6e86f4706ef0a0a95eb8c76c91ca..f3bdb5c187904869a87e0c688fad00f1bf42f6b3 100644 --- a/include/fileutils.h +++ b/include/fileutils.h @@ -86,19 +86,6 @@ int remove(const std::filesystem::path& path, bool erase = false); */ int removeAll(const std::filesystem::path& path, bool erase = false); -/** - * Wrappers for fstream opening that will convert paths to wstring - * on windows - */ -void openStream(std::ifstream& file, - const std::filesystem::path& path, - std::ios_base::openmode mode = std::ios_base::in); -void openStream(std::ofstream& file, - const std::filesystem::path& path, - std::ios_base::openmode mode = std::ios_base::out); -std::ifstream ifstream(const std::filesystem::path& path, std::ios_base::openmode mode = std::ios_base::in); -std::ofstream ofstream(const std::filesystem::path& path, std::ios_base::openmode mode = std::ios_base::out); - /** * Windows compatibility wrapper for checking read-only attribute */ diff --git a/src/connectionmanager.cpp b/src/connectionmanager.cpp index 0b97ac5afda8161cd326ff7cf5843b89711cbe44..238f4b44f5105d9ba06b00b8a2db475b1756412d 100644 --- a/src/connectionmanager.cpp +++ b/src/connectionmanager.cpp @@ -1306,10 +1306,10 @@ ConnectionManager::Impl::dhParams() const template<typename ID = dht::Value::Id> std::set<ID, std::less<>> -loadIdList(const std::string& path) +loadIdList(const std::filesystem::path& path) { std::set<ID, std::less<>> ids; - std::ifstream file = fileutils::ifstream(path); + std::ifstream file(path); if (!file.is_open()) { //JAMI_DBG("Could not load %s", path.c_str()); return ids; @@ -1333,7 +1333,7 @@ template<typename List = std::set<dht::Value::Id>> void saveIdList(const std::filesystem::path& path, const List& ids) { - std::ofstream file = fileutils::ofstream(path, std::ios::trunc | std::ios::binary); + std::ofstream file(path, std::ios::trunc | std::ios::binary); if (!file.is_open()) { //JAMI_ERR("Could not save to %s", path.c_str()); return; diff --git a/src/fileutils.cpp b/src/fileutils.cpp index 7ba5eb855dc7f4265f1b07bf2f43d254d59386ca..23aceff3d3afcd26724d30789174818aec8fc66b 100644 --- a/src/fileutils.cpp +++ b/src/fileutils.cpp @@ -153,7 +153,7 @@ std::vector<uint8_t> loadFile(const std::filesystem::path& path) { std::vector<uint8_t> buffer; - std::ifstream file = ifstream(path, std::ios::binary); + std::ifstream file(path, std::ios::binary); if (!file) throw std::runtime_error("Can't read file: " + path.string()); file.seekg(0, std::ios::end); @@ -170,7 +170,7 @@ loadFile(const std::filesystem::path& path) void saveFile(const std::filesystem::path& path, const uint8_t* data, size_t data_size, mode_t mode) { - std::ofstream file = fileutils::ofstream(path, std::ios::trunc | std::ios::binary); + std::ofstream file(path, std::ios::trunc | std::ios::binary); if (!file.is_open()) { //JAMI_ERR("Could not write data to %s", path.c_str()); return;