diff --git a/src/chat_gui/contact_chat_log.cpp b/src/chat_gui/contact_chat_log.cpp index d0c03b8..ca00259 100644 --- a/src/chat_gui/contact_chat_log.cpp +++ b/src/chat_gui/contact_chat_log.cpp @@ -65,7 +65,7 @@ namespace Context { } // Context -static constexpr float lerp(float a, float b, float t) { +static constexpr float lerp_f(float a, float b, float t) { return a + t * (b - a); } @@ -275,10 +275,10 @@ float ContactChatLog::render(bool window_focused, float time_delta, const std::v const float fade_frac = msg_reg->get(e).fade; ImVec4 res_color{ - lerp(orig_color.x, hi_color.x, fade_frac), - lerp(orig_color.y, hi_color.y, fade_frac), - lerp(orig_color.z, hi_color.z, fade_frac), - lerp(orig_color.w, hi_color.w, fade_frac), + lerp_f(orig_color.x, hi_color.x, fade_frac), + lerp_f(orig_color.y, hi_color.y, fade_frac), + lerp_f(orig_color.z, hi_color.z, fade_frac), + lerp_f(orig_color.w, hi_color.w, fade_frac), }; ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg1, ImGui::GetColorU32(res_color)); @@ -718,7 +718,7 @@ bool ContactChatLog::renderMessageBodyFile(Message3Registry& reg, const Message3 [this, o](const auto& path) { if (static_cast(o)) { // still valid // TODO: trim file? - o.emplace(path.generic_u8string()); + o.emplace(path.generic_string()); //_rmm.throwEventUpdate(reg, e); // TODO: block recursion _os.throwEventUpdate(o); @@ -939,7 +939,7 @@ bool ContactChatLog::renderMessageBodyFile(Message3Registry& reg, const Message3 _cb.setClipboardData({"text/uri-list", "text/x-moz-url"}, std::make_shared>(url.begin(), url.end())); } if (ImGui::MenuItem("copy filepath")) { - const auto file_path = std::filesystem::canonical(local_info.file_list.at(i).file_path).u8string(); //TODO: use generic over native? + const auto file_path = std::filesystem::canonical(local_info.file_list.at(i).file_path).string(); //TODO: use generic over native? ImGui::SetClipboardText(file_path.c_str()); } ImGui::EndPopup(); @@ -1019,7 +1019,7 @@ bool ContactChatLog::renderMessageBodyFile(Message3Registry& reg, const Message3 // TODO: try object interface first instead, then fall back to send with SingleInfoLocal //_rmm.sendFileObj(fc, o); std::filesystem::path path = o.get().file_path; - _rmm.sendFilePath(fc, path.filename().generic_u8string(), path.generic_u8string()); + _rmm.sendFilePath(fc, path.filename().generic_string(), path.generic_string()); } } ImGui::EndMenu(); @@ -1032,7 +1032,7 @@ bool ContactChatLog::renderMessageBodyFile(Message3Registry& reg, const Message3 _cb.setClipboardData({"text/uri-list", "text/x-moz-url"}, std::make_shared>(url.begin(), url.end())); } if (ImGui::MenuItem("copy filepath")) { - const auto file_path = std::filesystem::canonical(local_info.file_path).u8string(); //TODO: use generic over native? + const auto file_path = std::filesystem::canonical(local_info.file_path).string(); //TODO: use generic over native? ImGui::SetClipboardText(file_path.c_str()); } ImGui::EndPopup(); diff --git a/src/chat_gui/contact_window.cpp b/src/chat_gui/contact_window.cpp index 353c992..33d02f8 100644 --- a/src/chat_gui/contact_window.cpp +++ b/src/chat_gui/contact_window.cpp @@ -284,7 +284,7 @@ float ContactWindow::render( _fss.requestFile( [](const auto& path) -> bool { return std::filesystem::is_regular_file(path); }, [this](const auto& path){ - _rmm.sendFilePath(c, path.filename().generic_u8string(), path.generic_u8string()); + _rmm.sendFilePath(c, path.filename().generic_string(), path.generic_string()); }, [](){} ); @@ -585,7 +585,7 @@ void ContactWindow::pasteFile(const char* mime_type) { std::ofstream(tmp_file_path, std::ios_base::out | std::ios_base::binary) .write(reinterpret_cast(img_data.data()), img_data.size()); - _rmm.sendFilePath(c, tmp_file_name.str(), tmp_file_path.generic_u8string()); + _rmm.sendFilePath(c, tmp_file_name.str(), tmp_file_path.generic_string()); }, [](){} ); @@ -664,7 +664,7 @@ void ContactWindow::sendFilePath(std::string_view file_path) { return; } - _rmm.sendFilePath(c, path.filename().generic_u8string(), path.generic_u8string()); + _rmm.sendFilePath(c, path.filename().generic_string(), path.generic_string()); } void ContactWindow::sendFileList(const std::vector& list) { @@ -704,7 +704,7 @@ void ContactWindow::sendFileList(const std::vector& list) { std::ofstream(tmp_file_path, std::ios_base::out | std::ios_base::binary) .write(reinterpret_cast(img_data.data()), img_data.size()); - _rmm.sendFilePath(c, tmp_file_name.str(), tmp_file_path.generic_u8string()); + _rmm.sendFilePath(c, tmp_file_name.str(), tmp_file_path.generic_string()); }, [](){} )) { diff --git a/src/chat_gui/file_selector.cpp b/src/chat_gui/file_selector.cpp index c171cf7..3c55c02 100644 --- a/src/chat_gui/file_selector.cpp +++ b/src/chat_gui/file_selector.cpp @@ -61,7 +61,7 @@ void FileSelector::render(void) { std::filesystem::path current_path = _current_file_path; current_path.remove_filename(); - ImGui::Text("path: %s", _current_file_path.generic_u8string().c_str()); + ImGui::Text("path: %s", _current_file_path.generic_string().c_str()); // begin table with selectables constexpr ImGuiTableFlags table_flags = @@ -234,7 +234,7 @@ void FileSelector::render(void) { if (ImGui::TableNextColumn()) { try { - ImGui::TextUnformatted((dir_entry.path().filename().generic_u8string() + "/").c_str()); + ImGui::TextUnformatted((dir_entry.path().filename().generic_string() + "/").c_str()); } catch (...) {} } @@ -276,7 +276,7 @@ void FileSelector::render(void) { if (ImGui::TableNextColumn()) { try { - ImGui::TextUnformatted(file_entry.path().filename().generic_u8string().c_str()); + ImGui::TextUnformatted(file_entry.path().filename().generic_string().c_str()); } catch(...) {} } diff --git a/src/chat_gui/send_image_popup.cpp b/src/chat_gui/send_image_popup.cpp index f367794..edaeee7 100644 --- a/src/chat_gui/send_image_popup.cpp +++ b/src/chat_gui/send_image_popup.cpp @@ -199,7 +199,7 @@ bool SendImagePopup::sendFilePath( // file2 instead? } if (path_o.has_extension()) { - original_file_ext = path_o.extension().u8string(); + original_file_ext = path_o.extension().string(); } if (!load()) { diff --git a/src/sdl_clipboard_utils.cpp b/src/sdl_clipboard_utils.cpp index 61ef9f0..d68b6cc 100644 --- a/src/sdl_clipboard_utils.cpp +++ b/src/sdl_clipboard_utils.cpp @@ -97,20 +97,20 @@ std::string file_path_to_file_url(const std::filesystem::path& path) { std::string url {"file://"}; // special windows detection <.< // we detect a drive letter here - if (can_path.has_root_name() && can_path.root_name().generic_u8string().back() == ':') { - const std::string root_name = can_path.root_name().generic_u8string(); + if (can_path.has_root_name() && can_path.root_name().generic_string().back() == ':') { + const std::string root_name = can_path.root_name().generic_string(); // drive letters have a colon, which needs skipping the url escaping url += "/"; url += root_name; //url += "/"; // bugged, does not work (but it should, open msvc stl issue?) - //url += file_path_url_escape(can_path.lexically_proximate(can_path.root_name()).generic_u8string()); + //url += file_path_url_escape(can_path.lexically_proximate(can_path.root_name()).generic_string()); // remove drive letter - url += file_path_url_escape(can_path.generic_u8string().substr(root_name.size())); + url += file_path_url_escape(can_path.generic_string().substr(root_name.size())); } else { - url += file_path_url_escape(can_path.generic_u8string()); + url += file_path_url_escape(can_path.generic_string()); } return url; diff --git a/src/start_screen.cpp b/src/start_screen.cpp index bd17c83..9b8e3b3 100644 --- a/src/start_screen.cpp +++ b/src/start_screen.cpp @@ -73,7 +73,7 @@ StartScreen::StartScreen(const std::vector& args, SDL_Renderer if (real_tox_profile_path.is_relative()) { real_tox_profile_path = config_path_base / real_tox_profile_path; } - _tox_profile_path = real_tox_profile_path.u8string(); + _tox_profile_path = real_tox_profile_path.string(); } float display_scale = SDL_GetWindowDisplayScale(SDL_GetRenderWindow(renderer)); @@ -154,7 +154,7 @@ StartScreen::StartScreen(const std::vector& args, SDL_Renderer real_plugin_path = config_path_base / real_plugin_path; } - _queued_plugin_paths.push_back(real_plugin_path.u8string()); + _queued_plugin_paths.push_back(real_plugin_path.string()); } } } diff --git a/src/tox_avatar_manager.cpp b/src/tox_avatar_manager.cpp index 250dc56..78d45f6 100644 --- a/src/tox_avatar_manager.cpp +++ b/src/tox_avatar_manager.cpp @@ -101,7 +101,7 @@ void ToxAvatarManager::iterate(void) { std::string ToxAvatarManager::getAvatarPath(const ToxKey& key) const { const std::string_view avatar_save_path {_conf.get_string("ToxAvatarManager", "save_path").value()}; const auto file_path = std::filesystem::path(avatar_save_path) / getAvatarFileName(key); - return file_path.generic_u8string(); + return file_path.generic_string(); } std::string ToxAvatarManager::getAvatarFileName(const ToxKey& key) const { diff --git a/src/tox_client.cpp b/src/tox_client.cpp index d62e62b..1f6bbf8 100644 --- a/src/tox_client.cpp +++ b/src/tox_client.cpp @@ -223,7 +223,7 @@ void ToxClient::saveToxProfile(void) { } std::filesystem::path tmp_path = _tox_profile_path + ".tmp"; - tmp_path.replace_filename("." + tmp_path.filename().generic_u8string()); + tmp_path.replace_filename("." + tmp_path.filename().generic_string()); try { std::ofstream ofile{tmp_path, std::ios::binary}; diff --git a/external/solanaceae_object_store/src/solanaceae/object_store/backends/filesystem_storage_atomic.cpp index 05cad6a..37f411c 100644 --- a/external/solanaceae_object_store/src/solanaceae/object_store/backends/filesystem_storage_atomic.cpp +++ b/external/solanaceae_object_store/src/solanaceae/object_store/backends/filesystem_storage_atomic.cpp @@ -77,7 +77,7 @@ ObjectHandle FilesystemStorageAtomic::newObject(ByteSpan id, bool throw_construc oh.emplace(this); oh.emplace(this); oh.emplace(std::vector{id}); - oh.emplace(object_file_path.generic_u8string()); + oh.emplace(object_file_path.generic_string()); oh.emplace(_mft_new); // meta needs to be synced to file @@ -137,11 +137,11 @@ bool FilesystemStorageAtomic::write(Object o, std::function().path + ".meta" + metaFileTypeSuffix(meta_type) + ".tmp"; - meta_tmp_path.replace_filename("." + meta_tmp_path.filename().generic_u8string()); + meta_tmp_path.replace_filename("." + meta_tmp_path.filename().generic_string()); // TODO: make meta comp work with mem compressor - //auto meta_file_stack = buildFileStackWrite(std::string_view{meta_tmp_path.generic_u8string()}, meta_enc, meta_comp); + //auto meta_file_stack = buildFileStackWrite(std::string_view{meta_tmp_path.generic_string()}, meta_enc, meta_comp); std::stack> meta_file_stack; - meta_file_stack.push(std::make_unique(std::string_view{meta_tmp_path.generic_u8string()})); + meta_file_stack.push(std::make_unique(std::string_view{meta_tmp_path.generic_string()})); if (meta_file_stack.empty()) { std::cerr << "FS error: failed to create temporary meta file stack\n"; @@ -159,8 +159,8 @@ bool FilesystemStorageAtomic::write(Object o, std::function().path + ".tmp"; - data_tmp_path.replace_filename("." + data_tmp_path.filename().generic_u8string()); - auto data_file_stack = buildFileStackWrite(std::string_view{data_tmp_path.generic_u8string()}, data_enc, data_comp); + data_tmp_path.replace_filename("." + data_tmp_path.filename().generic_string()); + auto data_file_stack = buildFileStackWrite(std::string_view{data_tmp_path.generic_string()}, data_enc, data_comp); if (data_file_stack.empty()) { while (!meta_file_stack.empty()) { meta_file_stack.pop(); } std::filesystem::remove(meta_tmp_path); @@ -401,7 +401,7 @@ size_t FilesystemStorageAtomic::scanPath(std::string_view path) { } auto relative_path = std::filesystem::proximate(file_path, storage_path); - std::string id_str = relative_path.generic_u8string(); + std::string id_str = relative_path.generic_string(); // delete all '/' id_str.erase(std::remove(id_str.begin(), id_str.end(), '/'), id_str.end()); if (id_str.size() % 2 != 0) { @@ -416,8 +416,8 @@ size_t FilesystemStorageAtomic::scanPath(std::string_view path) { const char* meta_ext = ".meta.msgpack"; { // find meta // TODO: this as to know all possible extentions - bool has_meta_msgpack = std::filesystem::is_regular_file(file_path.generic_u8string() + ".meta.msgpack"); - bool has_meta_json = std::filesystem::is_regular_file(file_path.generic_u8string() + ".meta.json"); + bool has_meta_msgpack = std::filesystem::is_regular_file(file_path.generic_string() + ".meta.msgpack"); + bool has_meta_json = std::filesystem::is_regular_file(file_path.generic_string() + ".meta.json"); const size_t meta_sum = (has_meta_msgpack?1:0) + (has_meta_json?1:0) @@ -491,7 +491,7 @@ size_t FilesystemStorageAtomic::scanPath(std::string_view path) { Compression meta_comp {Compression::NONE}; nlohmann::json j; if (it.meta_ext == ".meta.msgpack") { - std::ifstream file(it.obj_path.generic_u8string() + it.meta_ext, std::ios::in | std::ios::binary); + std::ifstream file(it.obj_path.generic_string() + it.meta_ext, std::ios::in | std::ios::binary); if (!file.is_open()) { std::cout << "FS error: failed opening meta " << it.obj_path << "\n"; continue; @@ -558,7 +558,7 @@ size_t FilesystemStorageAtomic::scanPath(std::string_view path) { j = nlohmann::json::from_msgpack(binary_read, true, false); } else if (it.meta_ext == ".meta.json") { - std::ifstream file(it.obj_path.generic_u8string() + it.meta_ext, std::ios::in | std::ios::binary); + std::ifstream file(it.obj_path.generic_string() + it.meta_ext, std::ios::in | std::ios::binary); if (!file.is_open()) { std::cerr << "FS error: failed opening meta " << it.obj_path << "\n"; continue; @@ -586,7 +586,7 @@ size_t FilesystemStorageAtomic::scanPath(std::string_view path) { oh.emplace(meta_enc); oh.emplace(meta_comp); - oh.emplace(it.obj_path.generic_u8string()); + oh.emplace(it.obj_path.generic_string()); for (const auto& [k, v] : j.items()) { // type id from string hash diff --git a/external/solanaceae_tox/solanaceae/tox_messages/tox_transfer_manager.cpp index 4c5666a..9d63412 100644 --- a/external/solanaceae_tox/solanaceae/tox_messages/tox_transfer_manager.cpp +++ b/external/solanaceae_tox/solanaceae/tox_messages/tox_transfer_manager.cpp @@ -344,11 +344,11 @@ bool ToxTransferManager::setFilePath(ObjectHandle transfer, std::string_view fil file_size = file_info.file_size; } - transfer.emplace_or_replace(full_file_path.u8string()); - transfer.emplace_or_replace(full_file_path.u8string()); // ? + transfer.emplace_or_replace(full_file_path.string()); + transfer.emplace_or_replace(full_file_path.string()); // ? // huh? we also set file2i ? - auto file_impl = std::make_unique(full_file_path.u8string(), file_size, true); + auto file_impl = std::make_unique(full_file_path.string(), file_size, true); if (!file_impl->isGood()) { std::cerr << "TTM error: failed opening file '" << file_path << "'!\n"; return false; diff --git a/external/solanaceae_util/solanaceae/util/file_synced.cpp index 1a094f7..3899c6b 100644 --- a/external/solanaceae_util/solanaceae/util/file_synced.cpp +++ b/external/solanaceae_util/solanaceae/util/file_synced.cpp @@ -51,7 +51,7 @@ void write_to_file_synced(const std::filesystem::path& file_path, const uint8_t* void write_to_file_synced(const std::filesystem::path& file_path, const uint8_t* data, size_t data_size) { // cant use O_DIRECT, O_SYNC has to be enough - const auto fd = open(file_path.generic_u8string().c_str(), O_CREAT | O_WRONLY | O_TRUNC | O_SYNC, S_IRUSR | S_IWUSR /*| S_IRGRP*/); + const auto fd = open(file_path.generic_string().c_str(), O_CREAT | O_WRONLY | O_TRUNC | O_SYNC, S_IRUSR | S_IWUSR /*| S_IRGRP*/); if (fd == -1) { throw std::runtime_error("file creation error: " + std::string(strerror(errno))); }