| 112 | |
| 113 | template <typename Char, typename PathChar> |
| 114 | void write_escaped_path(basic_memory_buffer<Char>& quoted, |
| 115 | const std::filesystem::path& p, |
| 116 | const std::basic_string<PathChar>& native) { |
| 117 | if constexpr (std::is_same_v<Char, char> && |
| 118 | std::is_same_v<PathChar, wchar_t>) { |
| 119 | auto buf = basic_memory_buffer<wchar_t>(); |
| 120 | write_escaped_string<wchar_t>(std::back_inserter(buf), native); |
| 121 | bool valid = to_utf8<wchar_t>::convert(quoted, {buf.data(), buf.size()}); |
| 122 | FMT_ASSERT(valid, "invalid utf16"); |
| 123 | } else if constexpr (std::is_same_v<Char, PathChar>) { |
| 124 | write_escaped_string<std::filesystem::path::value_type>( |
| 125 | std::back_inserter(quoted), native); |
| 126 | } else { |
| 127 | write_escaped_string<Char>(std::back_inserter(quoted), p.string<Char>()); |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | #endif // FMT_CPP_LIB_FILESYSTEM |
| 132 | |