MCPcopy Create free account
hub / github.com/VSWSL/Arch-WSL / GetUserInput

Method GetUserInput

ArchWSL/Helpers.cpp:13–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11}
12
13std::wstring Helpers::GetUserInput(DWORD promptMsg, DWORD maxCharacters)
14{
15 Helpers::PrintMessage(promptMsg);
16 size_t bufferSize = maxCharacters + 1;
17 std::unique_ptr<wchar_t[]> inputBuffer(new wchar_t[bufferSize]);
18 std::wstring input;
19 if (wscanf_s(L"%s", inputBuffer.get(), (unsigned int)bufferSize) == 1) {
20 input = inputBuffer.get();
21 }
22
23 // Throw away any additional chracters that did not fit in the buffer.
24 wchar_t wch;
25 do {
26 wch = getwchar();
27
28 } while ((wch != L'\n') && (wch != WEOF));
29
30 return input;
31}
32
33void Helpers::PrintErrorMessage(HRESULT error)
34{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected