1 //===-- FileAction.cpp ------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
13 #include "lldb/Host/Windows/win32.h" // For O_NOCTTY
16 #include "lldb/Target/FileAction.h"
18 using namespace lldb_private;
20 //----------------------------------------------------------------------------
21 // FileAction member functions
22 //----------------------------------------------------------------------------
24 FileAction::FileAction()
25 : m_action(eFileActionNone)
35 m_action = eFileActionNone;
42 FileAction::GetPath() const
46 return m_path.c_str();
50 FileAction::Open(int fd, const char *path, bool read, bool write)
52 if ((read || write) && fd >= 0 && path && path[0])
54 m_action = eFileActionOpen;
57 m_arg = O_NOCTTY | O_CREAT | O_RDWR;
59 m_arg = O_NOCTTY | O_RDONLY;
61 m_arg = O_NOCTTY | O_CREAT | O_WRONLY;
73 FileAction::Close(int fd)
78 m_action = eFileActionClose;
85 FileAction::Duplicate(int fd, int dup_fd)
88 if (fd >= 0 && dup_fd >= 0)
90 m_action = eFileActionDuplicate;