1 //===-- FileAction.h --------------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef liblldb_Target_FileAction_h 11 #define liblldb_Target_FileAction_h 12 13 #include <string> 14 #include "lldb/Host/FileSpec.h" 15 16 namespace lldb_private 17 { 18 19 class FileAction 20 { 21 public: 22 enum Action 23 { 24 eFileActionNone, 25 eFileActionClose, 26 eFileActionDuplicate, 27 eFileActionOpen 28 }; 29 30 FileAction(); 31 32 void Clear(); 33 34 bool Close(int fd); 35 36 bool Duplicate(int fd, int dup_fd); 37 38 bool Open(int fd, const FileSpec &file_spec, bool read, bool write); 39 40 int GetFD()41 GetFD() const 42 { 43 return m_fd; 44 } 45 46 Action GetAction()47 GetAction() const 48 { 49 return m_action; 50 } 51 52 int GetActionArgument()53 GetActionArgument() const 54 { 55 return m_arg; 56 } 57 58 const char * 59 GetPath() const; 60 61 const FileSpec & 62 GetFileSpec() const; 63 64 void 65 Dump (Stream &stream) const; 66 67 protected: 68 Action m_action; // The action for this file 69 int m_fd; // An existing file descriptor 70 int m_arg; // oflag for eFileActionOpen*, dup_fd for eFileActionDuplicate 71 FileSpec m_file_spec; // A file spec to use for opening after fork or posix_spawn 72 }; 73 74 } // namespace lldb_private 75 76 #endif 77