Skip to content

Commit

Permalink
Revert "fileutils: migrate to boost::nowide"
Browse files Browse the repository at this point in the history
Causes issues with yaml-cpp. Reverting temporarily until we fix the issue.

Change-Id: I2df0823554ad87880bc965bdff4f4707a6129789
  • Loading branch information
aberaud committed Sep 8, 2022
1 parent cc2f9ef commit 7622604
Show file tree
Hide file tree
Showing 42 changed files with 275 additions and 238 deletions.
4 changes: 1 addition & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ if(MSVC)
"${CMAKE_CURRENT_SOURCE_DIR}/contrib/build/webrtc-audio-processing;"
"${CMAKE_CURRENT_SOURCE_DIR}/contrib/build/portaudio/include;"
"${CMAKE_CURRENT_SOURCE_DIR}/contrib/build/pjproject/pjmedia/include;"
"${CMAKE_CURRENT_SOURCE_DIR}/contrib/build/libgit2/include;"
"${CMAKE_CURRENT_SOURCE_DIR}/contrib/build/nowide/include;"
"${CMAKE_CURRENT_SOURCE_DIR}/contrib/build/libgit2/include"
)
endif()

Expand Down Expand Up @@ -282,7 +281,6 @@ if(MSVC)
${CMAKE_CURRENT_SOURCE_DIR}/contrib/build/webrtc-audio-processing/build/Release/webrtc-audio-processing.lib
${CMAKE_CURRENT_SOURCE_DIR}/contrib/build/portaudio/build/Release/portaudio_static_x64.lib
${CMAKE_CURRENT_SOURCE_DIR}/contrib/build/libgit2/msvc/Release/git2.lib
${CMAKE_CURRENT_SOURCE_DIR}/contrib/build/nowide/build/Release/nowide.lib
/ignore:4006"
)

Expand Down
10 changes: 5 additions & 5 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ B) With Meson

cd ../../
mkdir build
path_deps=`pwd`/contrib/`cc -dumpmachine`
export PATH=$path_deps/bin:$PATH
meson build -Dpkg_config_path=$path_deps/lib/pkgconfig -Dcmake_prefix_path=$path_deps
meson compile -C build
meson install -C build
export PATH=$PATH:`pwd`/contrib/`cc -dumpmachine`/bin
meson -Dpkg_config_path=`pwd`/contrib/`cc -dumpmachine`/lib/pkgconfig -Ddefault_library=static -Dinterfaces=dbus build
cd build
ninja
ninja install

Done !

Expand Down
3 changes: 1 addition & 2 deletions compat/msvc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
"yaml-cpp",
"libarchive",
"webrtc-audio-processing",
"libgit2",
"nowide"
"libgit2"
],
"configuration": "ReleaseLib_win32",
"project_paths": ["ring-daemon.vcxproj"]
Expand Down
2 changes: 0 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -618,8 +618,6 @@ AC_DEFINE_UNQUOTED([HAVE_LIBNATPMP],
[Define if you have libnatpmp])
AM_CONDITIONAL([BUILD_NATPMP], test "x$with_natpmp" = "xyes")

DAEMONLDFLAGS+=" -lnowide"

# SHM
dnl check for shm
AS_IF([test "x$with_dbus" == xyes],
Expand Down
1 change: 0 additions & 1 deletion contrib/src/nowide/SHA512SUMS

This file was deleted.

20 changes: 0 additions & 20 deletions contrib/src/nowide/package.json

This file was deleted.

21 changes: 0 additions & 21 deletions contrib/src/nowide/rules.mak

This file was deleted.

1 change: 0 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ depfmt = dependency('fmt', version: '>= 5.3')
depyamlcpp = dependency('yaml-cpp', version: '>= 0.5.1')
depjsoncpp = dependency('jsoncpp', version: '>= 1.6.5')
depzlib = dependency('zlib')
depnowide = dependency('nowide', method: 'cmake')

if get_option('interfaces').contains('dbus')
depdbuscpp = dependency('dbus-c++-1')
Expand Down
7 changes: 3 additions & 4 deletions src/archiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ extern "C" {
#endif

#include <sys/stat.h>
#include <nowide/fstream.hpp>
#include <nowide/convert.hpp>
#include <fstream>

using namespace std::literals;

Expand Down Expand Up @@ -106,7 +105,7 @@ accountToJsonValue(const std::map<std::string, std::string>& details)
|| i.first == DRing::Account::ConfProperties::TLS::CERTIFICATE_FILE
|| i.first == DRing::Account::ConfProperties::TLS::PRIVATE_KEY_FILE) {
// replace paths by the files content
nowide::ifstream ifs(i.second);
std::ifstream ifs = fileutils::ifstream(i.second);
std::string fileContent((std::istreambuf_iterator<char>(ifs)),
std::istreambuf_iterator<char>());
root[i.first] = fileContent;
Expand Down Expand Up @@ -219,7 +218,7 @@ gzFile
openGzip(const std::string& path, const char* mode)
{
#ifdef _WIN32
return gzopen_w(nowide::widen(path).c_str(), mode);
return gzopen_w(jami::to_wstring(path).c_str(), mode);
#else
return gzopen(path.c_str(), mode);
#endif
Expand Down
24 changes: 12 additions & 12 deletions src/data_transfer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

#include <thread>
#include <stdexcept>
#include <nowide/fstream.hpp>
#include <fstream>
#include <sstream>
#include <ios>
#include <iostream>
Expand Down Expand Up @@ -367,7 +367,7 @@ class SubOutgoingFileTransfer final : public DataTransfer
}

mutable std::shared_ptr<OptimisticMetaOutgoingInfo> metaInfo_;
mutable nowide::ifstream input_;
mutable std::ifstream input_;
mutable bool headerSent_ {false};
bool peerReady_ {false};
const std::string peerUri_;
Expand All @@ -385,7 +385,7 @@ SubOutgoingFileTransfer::SubOutgoingFileTransfer(DRing::DataTransferId tid,
, peerUri_(peerUri)
{
info_ = metaInfo_->info();
input_.open(info_.path, std::ios::in | std::ios::binary);
fileutils::openStream(input_, info_.path, std::ios::in | std::ios::binary);
if (!input_)
throw std::runtime_error("input file open failed");
metaInfo_->addLinkedTransfer(this);
Expand Down Expand Up @@ -510,7 +510,7 @@ class OutgoingFileTransfer final : public DataTransfer
OutgoingFileTransfer() = delete;

mutable std::shared_ptr<OptimisticMetaOutgoingInfo> metaInfo_;
mutable nowide::ifstream input_;
mutable std::ifstream input_;
mutable std::vector<std::shared_ptr<SubOutgoingFileTransfer>> subtransfer_;
};

Expand All @@ -519,7 +519,7 @@ OutgoingFileTransfer::OutgoingFileTransfer(DRing::DataTransferId tid,
const InternalCompletionCb& cb)
: DataTransfer(tid, cb)
{
input_.open(info.path, std::ios::binary);
fileutils::openStream(input_, info.path, std::ios::binary);
if (!input_)
throw std::runtime_error("input file open failed");

Expand Down Expand Up @@ -574,7 +574,7 @@ class IncomingFileTransfer final : public DataTransfer

DRing::DataTransferId internalId_;

nowide::ofstream fout_;
std::ofstream fout_;
std::mutex cbMtx_ {};
std::function<void(const std::string&)> onFilenameCb_ {};
};
Expand Down Expand Up @@ -614,7 +614,7 @@ IncomingFileTransfer::requestFilename(const std::function<void(const std::string
info_.accountId);
fileutils::recursive_mkdir(path);
auto filename = fmt::format("{}/{}", path, id);
nowide::ofstream file(filename);
fileutils::ofstream(filename);
if (not fileutils::isFile(filename))
throw std::system_error(errno, std::generic_category());
info_.path = filename;
Expand All @@ -628,7 +628,7 @@ IncomingFileTransfer::start()
if (!DataTransfer::start())
return false;

fout_.open(&info_.path[0], std::ios::binary);
fileutils::openStream(fout_, &info_.path[0], std::ios::binary);
if (!fout_) {
JAMI_ERR() << "[FTP] Can't open file " << info_.path;
return false;
Expand Down Expand Up @@ -741,7 +741,7 @@ OutgoingFile::OutgoingFile(const std::shared_ptr<ChannelSocket>& channel,
channel_->shutdown();
return;
}
stream_.open(info_.path, std::ios::binary | std::ios::in);
fileutils::openStream(stream_, info_.path, std::ios::binary | std::ios::in);
if (!stream_ || !stream_.is_open()) {
channel_->shutdown();
return;
Expand Down Expand Up @@ -815,7 +815,7 @@ IncomingFile::IncomingFile(const std::shared_ptr<ChannelSocket>& channel,
: FileInfo(channel, fileId, interactionId, info)
, sha3Sum_(sha3Sum)
{
stream_.open(info_.path, std::ios::binary | std::ios::out);
fileutils::openStream(stream_, info_.path, std::ios::binary | std::ios::out);
if (!stream_)
return;

Expand Down Expand Up @@ -925,7 +925,7 @@ class TransferManager::Impl
}
void saveWaiting()
{
nowide::ofstream file(waitingPath_, std::ios::trunc | std::ios::binary);
std::ofstream file(waitingPath_, std::ios::trunc | std::ios::binary);
msgpack::pack(file, waitingIds_);
}

Expand Down Expand Up @@ -1146,7 +1146,7 @@ TransferManager::info(const std::string& fileId,
progress = itI->second->info().bytesProgress;
return true;
} else if (fileutils::isFile(path)) {
nowide::ifstream transfer(path, std::ios::binary);
std::ifstream transfer(path, std::ios::binary);
transfer.seekg(0, std::ios::end);
progress = transfer.tellg();
if (itW != pimpl_->waitingIds_.end()) {
Expand Down
6 changes: 3 additions & 3 deletions src/data_transfer.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include <memory>
#include <string>
#include <nowide/fstream.hpp>
#include <fstream>
#include <optional>

namespace jami {
Expand Down Expand Up @@ -96,7 +96,7 @@ class IncomingFile : public FileInfo, public std::enable_shared_from_this<Incomi
{
return std::static_pointer_cast<IncomingFile>(shared_from_this());
}
nowide::ofstream stream_;
std::ofstream stream_;
std::string sha3Sum_ {};
};

Expand All @@ -114,7 +114,7 @@ class OutgoingFile : public FileInfo
void cancel() override;

private:
nowide::ifstream stream_;
std::ifstream stream_;
size_t start_ {0};
size_t end_ {0};
};
Expand Down
6 changes: 3 additions & 3 deletions src/debug_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

#include <chrono>
#include <cstdio>
#include <nowide/fstream.hpp>
#include <fstream>
#include <ios>
#include <ratio>
#include <string_view>
Expand Down Expand Up @@ -94,7 +94,7 @@ class WavWriter
AV_SAMPLE_FMT_FLTP,
AV_SAMPLE_FMT_DBL,
AV_SAMPLE_FMT_DBLP};
f_ = nowide::ofstream(filename, std::ios_base::out | std::ios_base::binary);
f_ = std::ofstream(filename, std::ios_base::out | std::ios_base::binary);
f_.imbue(std::locale::classic());
f_ << "RIFF----WAVEfmt ";
if (std::find(v.begin(), v.end(), format_) == v.end()) {
Expand Down Expand Up @@ -189,7 +189,7 @@ class WavWriter
}

private:
nowide::ofstream f_;
std::ofstream f_;
size_t dataChunk_ {0};
size_t factChunk_ {0};
size_t length_ {0};
Expand Down
Loading

0 comments on commit 7622604

Please sign in to comment.