LLDB  mainline
FileAction.h
Go to the documentation of this file.
1 //===-- FileAction.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_HOST_FILEACTION_H
10 #define LLDB_HOST_FILEACTION_H
11 
12 #include "lldb/Utility/FileSpec.h"
13 #include <string>
14 
15 namespace lldb_private {
16 
17 class FileAction {
18 public:
19  enum Action {
24  };
25 
26  FileAction();
27 
28  void Clear();
29 
30  bool Close(int fd);
31 
32  bool Duplicate(int fd, int dup_fd);
33 
34  bool Open(int fd, const FileSpec &file_spec, bool read, bool write);
35 
36  int GetFD() const { return m_fd; }
37 
38  Action GetAction() const { return m_action; }
39 
40  int GetActionArgument() const { return m_arg; }
41 
42  llvm::StringRef GetPath() const;
43 
44  const FileSpec &GetFileSpec() const;
45 
46  void Dump(Stream &stream) const;
47 
48 protected:
49  Action m_action; // The action for this file
50  int m_fd; // An existing file descriptor
51  int m_arg; // oflag for eFileActionOpen*, dup_fd for eFileActionDuplicate
52  FileSpec
53  m_file_spec; // A file spec to use for opening after fork or posix_spawn
54 };
55 
56 } // namespace lldb_private
57 
58 #endif
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
void Dump(Stream &stream) const
Definition: FileAction.cpp:71
A file utility class.
Definition: FileSpec.h:55
Action GetAction() const
Definition: FileAction.h:38
bool Open(int fd, const FileSpec &file_spec, bool read, bool write)
Definition: FileAction.cpp:33
llvm::StringRef GetPath() const
Definition: FileAction.cpp:29
const FileSpec & GetFileSpec() const
Definition: FileAction.cpp:31
bool Duplicate(int fd, int dup_fd)
Definition: FileAction.cpp:61
int GetActionArgument() const
Definition: FileAction.h:40