LLDB mainline
FileWindows.h
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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_WINDOWS_FILEWINDOWS_H
10#define LLDB_HOST_WINDOWS_FILEWINDOWS_H
11
12#include "lldb/Host/FileBase.h"
13
14namespace lldb_private {
15
16/// \class NativeFileWindows FileWindows.h "lldb/Host/windows/FileWindows.h"
17/// Windows implementation of NativeFile.
19public:
20 NativeFileWindows() = default;
21
22 NativeFileWindows(FILE *fh, OpenOptions options, bool transfer_ownership);
23
24 NativeFileWindows(int fd, OpenOptions options, bool transfer_ownership);
25
26 // Bring the inherited single-argument Read/Write into scope so they aren't
27 // hidden by the positional overloads declared below.
30
32 Status Sync() override;
33 Status Read(void *dst, size_t &num_bytes, off_t &offset) override;
34 Status Write(const void *src, size_t &num_bytes, off_t &offset) override;
35
36 static char ID;
37 bool isA(const void *classID) const override {
38 return classID == &ID || NativeFileBase::isA(classID);
39 }
40 static bool classof(const File *file) { return file->isA(&ID); }
41
42protected:
43 void CalculateInteractiveAndTerminal() override;
44
45 int Fileno(FILE *fh) const override;
46 int Dup(int fd) const override;
47
48 bool TryWriteStreamUnlocked(const void *buf, size_t &num_bytes,
49 Status &error) override;
50
51private:
52 /// Set when this file wraps stdin/stdout/stderr connected to a console;
53 /// triggers the raw_fd_ostream path for correct non-ASCII output.
55
58};
59
60} // namespace lldb_private
61
62#endif // LLDB_HOST_WINDOWS_FILEWINDOWS_H
static llvm::raw_ostream & error(Stream &strm)
An abstract base class for files.
Definition FileBase.h:34
virtual bool isA(const void *classID) const
Definition FileBase.h:363
lldb::file_t WaitableHandle
Definition IOObject.h:29
Status Write(const void *buf, size_t &num_bytes) override
Write bytes from buf to a file at the current file position.
Definition File.cpp:525
bool isA(const void *classID) const override
Definition FileBase.h:415
Status Read(void *buf, size_t &num_bytes) override
Read bytes from a file from the current file position into buf.
Definition File.cpp:457
const NativeFileWindows & operator=(const NativeFileWindows &)=delete
int Fileno(FILE *fh) const override
Map a stream to its underlying file descriptor.
Status Sync() override
Sync to disk.
void CalculateInteractiveAndTerminal() override
Refresh the cached interactive / terminal / color flags by inspecting the underlying descriptor.
bool TryWriteStreamUnlocked(const void *buf, size_t &num_bytes, Status &error) override
Hook for stream writes that bypass the default fwrite path.
NativeFileWindows(const NativeFileWindows &)=delete
static bool classof(const File *file)
Definition FileWindows.h:40
Status Write(const void *src, size_t &num_bytes, off_t &offset) override
Write bytes to a file at the specified file offset.
WaitableHandle GetWaitableHandle() override
Get a handle that can be used for OS polling interfaces, such as WaitForMultipleObjects,...
bool isA(const void *classID) const override
Definition FileWindows.h:37
Status Read(void *dst, size_t &num_bytes, off_t &offset) override
Read bytes from a file from the specified file offset.
bool m_is_windows_console
Set when this file wraps stdin/stdout/stderr connected to a console; triggers the raw_fd_ostream path...
Definition FileWindows.h:54
int Dup(int fd) const override
Duplicate a file descriptor.
An error handling class.
Definition Status.h:118
A class that represents a running process on the host machine.