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
13#include <string>
14
15namespace lldb_private {
16
18public:
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
48protected:
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
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
Action GetAction() const
Definition: FileAction.h:38
bool Duplicate(int fd, int dup_fd)
Definition: FileAction.cpp:62
void Dump(Stream &stream) const
Definition: FileAction.cpp:72
llvm::StringRef GetPath() const
Definition: FileAction.cpp:28
int GetActionArgument() const
Definition: FileAction.h:40
const FileSpec & GetFileSpec() const
Definition: FileAction.cpp:32
bool Open(int fd, const FileSpec &file_spec, bool read, bool write)
Definition: FileAction.cpp:34
A file utility class.
Definition: FileSpec.h:56
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
A class that represents a running process on the host machine.