summaryrefslogtreecommitdiff
path: root/include/lldb/Target/FileAction.h
blob: 907c4d937beb9cf445e94ce4f52c88adc2cee775 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//===-- FileAction.h --------------------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef liblldb_Target_FileAction_h
#define liblldb_Target_FileAction_h

#include <string>
#include "lldb/Host/FileSpec.h"

namespace lldb_private
{

class FileAction
{
  public:
    enum Action
    {
        eFileActionNone,
        eFileActionClose,
        eFileActionDuplicate,
        eFileActionOpen
    };

    FileAction();

    void Clear();

    bool Close(int fd);

    bool Duplicate(int fd, int dup_fd);

    bool Open(int fd, const FileSpec &file_spec, bool read, bool write);

    int
    GetFD() const
    {
        return m_fd;
    }

    Action
    GetAction() const
    {
        return m_action;
    }

    int
    GetActionArgument() const
    {
        return m_arg;
    }

    const char *
    GetPath() const;

    const FileSpec &
    GetFileSpec() const;

    void
    Dump (Stream &stream) const;

  protected:
    Action m_action;      // The action for this file
    int m_fd;             // An existing file descriptor
    int m_arg;            // oflag for eFileActionOpen*, dup_fd for eFileActionDuplicate
    FileSpec m_file_spec; // A file spec to use for opening after fork or posix_spawn
};

} // namespace lldb_private

#endif