Go to the documentation of this file.
9 #ifndef LLDB_HOST_FILE_H
10 #define LLDB_HOST_FILE_H
17 #include "llvm/ADT/BitmaskEnum.h"
23 #include <sys/types.h>
72 static llvm::Expected<const char *>
90 Status Read(
void *buf,
size_t &num_bytes)
override;
105 Status Write(
const void *buf,
size_t &num_bytes)
override;
240 virtual Status Read(
void *dst,
size_t &num_bytes, off_t &offset);
265 virtual Status Write(
const void *src,
size_t &num_bytes, off_t &offset);
306 virtual
size_t PrintfVarArg(const
char *format, va_list args);
323 return opts.takeError();
363 virtual bool isA(
const void *classID)
const {
return classID == &
ID; }
396 Status Read(
void *buf,
size_t &num_bytes)
override;
397 Status Write(
const void *buf,
size_t &num_bytes)
override;
406 Status Read(
void *dst,
size_t &num_bytes, off_t &offset)
override;
407 Status Write(
const void *src,
size_t &num_bytes, off_t &offset)
override;
410 size_t PrintfVarArg(
const char *format, va_list args)
override;
411 llvm::Expected<OpenOptions>
GetOptions()
const override;
414 bool isA(
const void *classID)
const override {
449 static llvm::Expected<Options>
OptionsFromURL(llvm::StringRef urlqs);
451 static llvm::Expected<std::unique_ptr<SerialPort>>
453 bool transfer_ownership);
462 bool isA(
const void *classID)
const override {
469 bool transfer_ownership);
479 #endif // LLDB_HOST_FILE_H
virtual bool isA(const void *classID) const
Status Sync() override
Sync to disk.
virtual Status Sync()
Sync to disk.
WaitableHandle GetWaitableHandle() override
Get a handle that can be used for OS polling interfaces, such as WaitForMultipleObjects,...
static mode_t ConvertOpenOptionsForPOSIXOpen(OpenOptions open_options)
uint32_t GetPermissions(Status &error) const
Get the permissions for a this file.
FILE * GetStream() override
Get the underlying libc stream for this file, or NULL.
Status Read(void *buf, size_t &num_bytes) override
Read bytes from a file from the current file position into buf.
static llvm::Expected< std::unique_ptr< SerialPort > > Create(int fd, OpenOptions options, Options serial_options, bool transfer_ownership)
bool GetIsInteractive()
Return true if this file is interactive.
__attribute__((always_inline)) int uuid_is_null(uuid_t uuid)
off_t SeekFromStart(off_t offset, Status *error_ptr=nullptr) override
Seek to an offset relative to the beginning of the file.
std::optional< Terminal::Parity > Parity
bool StreamIsValid() const
bool DescriptorIsValid() const
Status Flush() override
Flush the current stream.
bool GetIsRealTerminal()
Return true if this file from a real terminal.
const File & operator=(const File &)=delete
std::mutex offset_access_mutex
NativeFile(FILE *fh, bool transfer_ownership)
NativeFile(int fd, OpenOptions options, bool transfer_ownership)
@ eOpenOptionCanCreateNewOnly
virtual Status GetFileSpec(FileSpec &file_spec) const
Get the file specification for this file, if possible.
static bool classof(const File *file)
Status Close() override
Flush any buffers and release any resources owned by the file.
Status Close() override
Flush any buffers and release any resources owned by the file.
static llvm::Expected< const char * > GetStreamOpenModeFromOptions(OpenOptions options)
LazyBool m_supports_colors
bool IsValid() const override
IsValid.
virtual Status Flush()
Flush the current stream.
static llvm::raw_ostream & error(Stream &strm)
static bool DescriptorIsValid(int descriptor)
const SerialPort & operator=(const SerialPort &)=delete
virtual off_t SeekFromStart(off_t offset, Status *error_ptr=nullptr)
Seek to an offset relative to the beginning of the file.
const NativeFile & operator=(const NativeFile &)=delete
off_t SeekFromCurrent(off_t offset, Status *error_ptr=nullptr) override
Seek to an offset relative to the current file position.
void CalculateInteractiveAndTerminal()
virtual llvm::Expected< OpenOptions > GetOptions() const
Return the OpenOptions for this file.
LazyBool m_is_real_terminal
bool isA(const void *classID) const override
llvm::Expected< OpenOptions > GetOptions() const override
Return the OpenOptions for this file.
@ LLVM_MARK_AS_BITMASK_ENUM
LazyBool m_is_interactive
static llvm::Expected< Options > OptionsFromURL(llvm::StringRef urlqs)
SerialPort(int fd, OpenOptions options, Options serial_options, bool transfer_ownership)
LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE()
@ eOpenOptionDontFollowSymlinks
std::optional< unsigned int > StopBits
size_t virtual size_t PrintfVarArg(const char *format, va_list args)
Output printf formatted output to the stream.
size_t PrintfVarArg(const char *format, va_list args) override
Output printf formatted output to the stream.
Status Close() override
Flush any buffers and release any resources owned by the file.
static int kInvalidDescriptor
bool isA(const void *classID) const override
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
bool IsValid() const override
IsValid.
Status GetFileSpec(FileSpec &file_spec) const override
Get the file specification for this file, if possible.
static bool classof(const File *file)
virtual int GetDescriptor() const
Get underlying OS file descriptor for this file, or kInvalidDescriptor.
static llvm::Expected< OpenOptions > GetOptionsFromMode(llvm::StringRef mode)
llvm::Expected< const char * > GetOpenMode() const
A class that represents a running process on the host machine.
Status Read(void *buf, size_t &num_bytes) override
Read bytes from a file from the current file position into buf.
int GetDescriptor() const override
Get underlying OS file descriptor for this file, or kInvalidDescriptor.
Status Write(const void *buf, size_t &num_bytes) override
Write bytes from buf to a file at the current file position.
Status Write(const void *buf, size_t &num_bytes) override
Write bytes from buf to a file at the current file position.
std::optional< Terminal::ParityCheck > ParityCheck
virtual FILE * GetStream()
Get the underlying libc stream for this file, or NULL.
bool GetIsTerminalWithColors()
Return true if this file is a terminal which supports colors.
WaitableHandle GetWaitableHandle() override
Get a handle that can be used for OS polling interfaces, such as WaitForMultipleObjects,...
virtual off_t SeekFromEnd(off_t offset, Status *error_ptr=nullptr)
Seek to an offset relative to the end of the file.
std::optional< unsigned int > BaudRate
static bool classof(const File *file)
virtual off_t SeekFromCurrent(off_t offset, Status *error_ptr=nullptr)
Seek to an offset relative to the current file position.
static FILE * kInvalidStream
off_t SeekFromEnd(off_t offset, Status *error_ptr=nullptr) override
Seek to an offset relative to the end of the file.
bool IsValid() const override
IsValid.