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 = eFileActionNone; // The action for this file
50  int m_fd = -1; // An existing file descriptor
51  int m_arg = -1; // 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
lldb_private::FileAction::Close
bool Close(int fd)
Definition: FileAction.cpp:51
lldb_private::FileAction::eFileActionDuplicate
@ eFileActionDuplicate
Definition: FileAction.h:22
lldb_private::Stream
Definition: Stream.h:28
lldb_private::FileAction::Duplicate
bool Duplicate(int fd, int dup_fd)
Definition: FileAction.cpp:60
lldb_private::FileAction
Definition: FileAction.h:17
lldb_private::FileAction::m_arg
int m_arg
Definition: FileAction.h:51
lldb_private::FileAction::Open
bool Open(int fd, const FileSpec &file_spec, bool read, bool write)
Definition: FileAction.cpp:32
lldb_private::FileAction::m_fd
int m_fd
Definition: FileAction.h:50
lldb_private::FileSpec
Definition: FileSpec.h:56
lldb_private::FileAction::Dump
void Dump(Stream &stream) const
Definition: FileAction.cpp:70
lldb_private::FileAction::GetFD
int GetFD() const
Definition: FileAction.h:36
lldb_private::FileAction::Clear
void Clear()
Definition: FileAction.cpp:21
lldb_private::FileAction::GetAction
Action GetAction() const
Definition: FileAction.h:38
lldb_private::FileAction::eFileActionClose
@ eFileActionClose
Definition: FileAction.h:21
lldb_private::FileAction::GetPath
llvm::StringRef GetPath() const
Definition: FileAction.cpp:28
lldb_private::FileAction::eFileActionOpen
@ eFileActionOpen
Definition: FileAction.h:23
lldb_private::FileAction::eFileActionNone
@ eFileActionNone
Definition: FileAction.h:20
lldb_private::FileAction::m_action
Action m_action
Definition: FileAction.h:49
lldb_private::FileAction::Action
Action
Definition: FileAction.h:19
lldb_private::FileAction::GetFileSpec
const FileSpec & GetFileSpec() const
Definition: FileAction.cpp:30
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::FileAction::m_file_spec
FileSpec m_file_spec
Definition: FileAction.h:53
FileSpec.h
lldb_private::FileAction::FileAction
FileAction()
Definition: FileAction.cpp:19
lldb_private::FileAction::GetActionArgument
int GetActionArgument() const
Definition: FileAction.h:40