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 12#include "lldb/Utility/FileSpec.h" 13#include <string> 14 15namespace lldb_private { 16 17class FileAction { 18public: 19 enum Action { 20 eFileActionNone, 21 eFileActionClose, 22 eFileActionDuplicate, 23 eFileActionOpen 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; // The action for this file 50 int m_fd; // An existing file descriptor 51 int m_arg; // oflag for eFileActionOpen*, dup_fd for eFileActionDuplicate 52 FileSpec 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 59