|
23 | 23 | namespace nativeapi::detail { |
24 | 24 | namespace { |
25 | 25 | constexpr int kMaxDimension = 32768; |
| 26 | +std::string PathToUtf8(const std::filesystem::path& path) { |
| 27 | + auto utf8 = path.u8string(); |
| 28 | + return std::string(reinterpret_cast<const char*>(utf8.data()), utf8.size()); |
| 29 | +} |
26 | 30 | bool FrameValid(const CaptureFrame& frame) { |
27 | 31 | return frame.width > 0 && frame.height > 0 && frame.width <= kMaxDimension && |
28 | 32 | frame.height <= kMaxDimension && |
@@ -69,7 +73,7 @@ bool ValidRecordingPath(const std::string& path) { |
69 | 73 | try { |
70 | 74 | auto p = std::filesystem::u8path(path); |
71 | 75 | if (!p.is_absolute()) return false; |
72 | | - auto extension = p.extension().u8string(); |
| 76 | + auto extension = PathToUtf8(p.extension()); |
73 | 77 | std::transform(extension.begin(), extension.end(), extension.begin(), |
74 | 78 | [](unsigned char c) { return char(std::tolower(c)); }); |
75 | 79 | return extension == ".mp4"; |
@@ -142,8 +146,8 @@ bool CaptureOutputFile::Create(const std::string& destination, std::string& erro |
142 | 146 | auto directory = path.parent_path() / |
143 | 147 | (".nativeapi-recording-" + std::to_string(random()) + "-" + std::to_string(random())); |
144 | 148 | if (std::filesystem::create_directory(directory, ec)) { |
145 | | - directory_ = directory.u8string(); |
146 | | - temporary_ = (directory / "video.mp4").u8string(); |
| 149 | + directory_ = PathToUtf8(directory); |
| 150 | + temporary_ = PathToUtf8(directory / "video.mp4"); |
147 | 151 | destination_ = destination; |
148 | 152 | return true; |
149 | 153 | } |
|
0 commit comments