| 202 | } |
| 203 | |
| 204 | void WriteAllTextToUtf8TextFile( |
| 205 | std::wstring const& Path, |
| 206 | std::string& Content) |
| 207 | { |
| 208 | winrt::file_handle FileHandle; |
| 209 | |
| 210 | FileHandle.attach(::MileCreateFile( |
| 211 | Path.c_str(), |
| 212 | GENERIC_WRITE, |
| 213 | FILE_SHARE_WRITE, |
| 214 | nullptr, |
| 215 | CREATE_ALWAYS, |
| 216 | FILE_FLAG_SEQUENTIAL_SCAN, |
| 217 | nullptr)); |
| 218 | if (!FileHandle) |
| 219 | { |
| 220 | winrt::throw_last_error(); |
| 221 | } |
| 222 | |
| 223 | DWORD NumberOfBytesWritten = 0; |
| 224 | |
| 225 | const std::string BOM = "\xEF\xBB\xBF"; |
| 226 | |
| 227 | winrt::check_bool(::MileWriteFile( |
| 228 | FileHandle.get(), |
| 229 | BOM.c_str(), |
| 230 | static_cast<DWORD>(BOM.size()), |
| 231 | &NumberOfBytesWritten)); |
| 232 | |
| 233 | winrt::check_bool(::MileWriteFile( |
| 234 | FileHandle.get(), |
| 235 | Content.c_str(), |
| 236 | static_cast<DWORD>(Content.size()), |
| 237 | &NumberOfBytesWritten)); |
| 238 | } |
| 239 | |
| 240 | std::wstring GetAbsolutePath( |
| 241 | std::wstring const& FileName) |
no outgoing calls
no test coverage detected