MCPcopy Create free account
hub / github.com/M2Team/NanaBox / WriteAllTextToUtf8TextFile

Function WriteAllTextToUtf8TextFile

NanaBox/Utils.cpp:204–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202}
203
204void 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
240std::wstring GetAbsolutePath(
241 std::wstring const& FileName)

Callers 4

OnCloseMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected