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 "lldb/Utility/FileSpec.h" 14 #include <string> 15 16 namespace lldb_private { 17 18 class FileAction { 19 public: 20 enum Action { 21 eFileActionNone, 22 eFileActionClose, 23 eFileActionDuplicate, 24 eFileActionOpen 25 }; 26 27 FileAction(); 28 29 void Clear(); 30 31 bool Close(int fd); 32 33 bool Duplicate(int fd, int dup_fd); 34 35 bool Open(int fd, const FileSpec &file_spec, bool read, bool write); 36 GetFD()37 int GetFD() const { return m_fd; } 38 GetAction()39 Action GetAction() const { return m_action; } 40 GetActionArgument()41 int GetActionArgument() const { return m_arg; } 42 43 llvm::StringRef GetPath() const; 44 45 const FileSpec &GetFileSpec() const; 46 47 void Dump(Stream &stream) const; 48 49 protected: 50 Action m_action; // The action for this file 51 int m_fd; // An existing file descriptor 52 int m_arg; // oflag for eFileActionOpen*, dup_fd for eFileActionDuplicate 53 FileSpec 54 m_file_spec; // A file spec to use for opening after fork or posix_spawn 55 }; 56 57 } // namespace lldb_private 58 59 #endif 60