Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame] | 1 | //===-- ConnectionGenericFileWindows.h --------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #ifndef liblldb_Host_windows_ConnectionGenericFileWindows_h_ |
| 10 | #define liblldb_Host_windows_ConnectionGenericFileWindows_h_ |
| 11 | |
| 12 | #include "lldb/Host/windows/windows.h" |
| 13 | #include "lldb/Utility/Connection.h" |
| 14 | #include "lldb/lldb-types.h" |
| 15 | |
| 16 | namespace lldb_private { |
| 17 | |
| 18 | class Status; |
| 19 | |
| 20 | class ConnectionGenericFile : public lldb_private::Connection { |
| 21 | public: |
| 22 | ConnectionGenericFile(); |
| 23 | |
| 24 | ConnectionGenericFile(lldb::file_t file, bool owns_file); |
| 25 | |
| 26 | ~ConnectionGenericFile() override; |
| 27 | |
| 28 | bool IsConnected() const override; |
| 29 | |
| 30 | lldb::ConnectionStatus Connect(llvm::StringRef s, Status *error_ptr) override; |
| 31 | |
| 32 | lldb::ConnectionStatus Disconnect(Status *error_ptr) override; |
| 33 | |
| 34 | size_t Read(void *dst, size_t dst_len, const Timeout<std::micro> &timeout, |
| 35 | lldb::ConnectionStatus &status, Status *error_ptr) override; |
| 36 | |
| 37 | size_t Write(const void *src, size_t src_len, lldb::ConnectionStatus &status, |
| 38 | Status *error_ptr) override; |
| 39 | |
| 40 | std::string GetURI() override; |
| 41 | |
| 42 | bool InterruptRead() override; |
| 43 | |
| 44 | protected: |
| 45 | OVERLAPPED m_overlapped; |
| 46 | HANDLE m_file; |
| 47 | HANDLE m_event_handles[2]; |
| 48 | bool m_owns_file; |
| 49 | LARGE_INTEGER m_file_position; |
| 50 | |
| 51 | enum { kBytesAvailableEvent, kInterruptEvent }; |
| 52 | |
| 53 | private: |
| 54 | void InitializeEventHandles(); |
| 55 | void IncrementFilePointer(DWORD amount); |
| 56 | |
| 57 | std::string m_uri; |
| 58 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame^] | 59 | ConnectionGenericFile(const ConnectionGenericFile &) = delete; |
| 60 | const ConnectionGenericFile & |
| 61 | operator=(const ConnectionGenericFile &) = delete; |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame] | 62 | }; |
| 63 | } |
| 64 | |
| 65 | #endif |