Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:48

0001 //===-- FileAction.h --------------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_HOST_FILEACTION_H
0010 #define LLDB_HOST_FILEACTION_H
0011 
0012 #include "lldb/Utility/FileSpec.h"
0013 #include <string>
0014 
0015 namespace lldb_private {
0016 
0017 class FileAction {
0018 public:
0019   enum Action {
0020     eFileActionNone,
0021     eFileActionClose,
0022     eFileActionDuplicate,
0023     eFileActionOpen
0024   };
0025 
0026   FileAction();
0027 
0028   void Clear();
0029 
0030   bool Close(int fd);
0031 
0032   bool Duplicate(int fd, int dup_fd);
0033 
0034   bool Open(int fd, const FileSpec &file_spec, bool read, bool write);
0035 
0036   int GetFD() const { return m_fd; }
0037 
0038   Action GetAction() const { return m_action; }
0039 
0040   int GetActionArgument() const { return m_arg; }
0041 
0042   llvm::StringRef GetPath() const;
0043 
0044   const FileSpec &GetFileSpec() const;
0045 
0046   void Dump(Stream &stream) const;
0047 
0048 protected:
0049   Action m_action = eFileActionNone; // The action for this file
0050   int m_fd = -1;                     // An existing file descriptor
0051   int m_arg = -1; // oflag for eFileActionOpen*, dup_fd for eFileActionDuplicate
0052   FileSpec
0053       m_file_spec; // A file spec to use for opening after fork or posix_spawn
0054 };
0055 
0056 } // namespace lldb_private
0057 
0058 #endif