| 1 | /*++ |
| 2 | |
| 3 | Copyright (c) Microsoft. All rights reserved. |
| 4 | |
| 5 | Module Name: |
| 6 | |
| 7 | ConsoleProgressBar.h |
| 8 | |
| 9 | Abstract: |
| 10 | |
| 11 | This file contains the ConsoleProgressBar definition |
| 12 | |
| 13 | --*/ |
| 14 | |
| 15 | #pragma once |
| 16 | #include "windows.h" |
| 17 | |
| 18 | namespace wsl::windows::common { |
| 19 | class ConsoleProgressBar |
| 20 | { |
| 21 | public: |
| 22 | ConsoleProgressBar(); |
| 23 | |
| 24 | HRESULT |
| 25 | Print(_In_ uint64_t progress, _In_ uint64_t total); |
| 26 | |
| 27 | HRESULT |
| 28 | Clear(); |
| 29 | |
| 30 | private: |
| 31 | HRESULT |
| 32 | PrintAndResetPosition(_In_ LPCWSTR string) const; |
| 33 | |
| 34 | static bool HandleIsConsole(_In_ HANDLE handle); |
| 35 | |
| 36 | bool m_isOutputConsole; |
| 37 | HANDLE m_outputHandle; |
| 38 | wil::unique_hlocal_string m_progressString; |
| 39 | uint64_t m_previousProgress = 0; |
| 40 | uint64_t m_previousTotal = 0; |
| 41 | }; |
| 42 | } // namespace wsl::windows::common |