1 //===-- SBFile.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 LLDB_SBFile_h_
10 #define LLDB_SBFile_h_
11 
12 #include "lldb/API/SBDefines.h"
13 
14 namespace lldb {
15 
16 class LLDB_API SBFile {
17   friend class SBInstruction;
18   friend class SBInstructionList;
19   friend class SBDebugger;
20   friend class SBCommandReturnObject;
21   friend class SBProcess;
22 
23 public:
24   SBFile();
25   SBFile(FileSP file_sp);
26   SBFile(FILE *file, bool transfer_ownership);
27   SBFile(int fd, const char *mode, bool transfer_ownership);
28   ~SBFile();
29 
30   SBError Read(uint8_t *buf, size_t num_bytes, size_t *bytes_read);
31   SBError Write(const uint8_t *buf, size_t num_bytes, size_t *bytes_written);
32   SBError Flush();
33   bool IsValid() const;
34   SBError Close();
35 
36   operator bool() const;
37   bool operator!() const;
38 
39   FileSP GetFile() const;
40 
41 private:
42   FileSP m_opaque_sp;
43 };
44 
45 } // namespace lldb
46 
47 #endif // LLDB_SBFile_h_
48