LLDB mainline
FilePosix.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_POSIX_FILEPOSIX_H
10#define LLDB_HOST_POSIX_FILEPOSIX_H
11
12#include "lldb/Host/FileBase.h"
13
14namespace lldb_private {
15
16/// \class NativeFilePosix FilePosix.h "lldb/Host/posix/FilePosix.h"
17/// POSIX implementation of NativeFile.
19public:
20 NativeFilePosix() = default;
21
22 NativeFilePosix(FILE *fh, OpenOptions options, bool transfer_ownership);
23
24 NativeFilePosix(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
31 Status GetFileSpec(FileSpec &file_spec) const override;
33 Status Sync() override;
34 Status Read(void *dst, size_t &num_bytes, off_t &offset) override;
35 Status Write(const void *src, size_t &num_bytes, off_t &offset) override;
36
37 static char ID;
38 bool isA(const void *classID) const override {
39 return classID == &ID || NativeFileBase::isA(classID);
40 }
41 static bool classof(const File *file) { return file->isA(&ID); }
42
43protected:
44 void CalculateInteractiveAndTerminal() override;
45
46private:
48 const NativeFilePosix &operator=(const NativeFilePosix &) = delete;
49};
50
51} // namespace lldb_private
52
53#endif // LLDB_HOST_POSIX_FILEPOSIX_H
A file utility class.
Definition FileSpec.h:57
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
Status Read(void *dst, size_t &num_bytes, off_t &offset) override
Read bytes from a file from the specified file offset.
Status Sync() override
Sync to disk.
Definition FilePosix.cpp:65
const NativeFilePosix & operator=(const NativeFilePosix &)=delete
WaitableHandle GetWaitableHandle() override
Get a handle that can be used for OS polling interfaces, such as WaitForMultipleObjects,...
Definition FilePosix.cpp:60
Status Write(const void *src, size_t &num_bytes, off_t &offset) override
Write bytes to a file at the specified file offset.
void CalculateInteractiveAndTerminal() override
Refresh the cached interactive / terminal / color flags by inspecting the underlying descriptor.
Definition FilePosix.cpp:76
NativeFilePosix(const NativeFilePosix &)=delete
static bool classof(const File *file)
Definition FilePosix.h:41
bool isA(const void *classID) const override
Definition FilePosix.h:38
Status GetFileSpec(FileSpec &file_spec) const override
Get the file specification for this file, if possible.
Definition FilePosix.cpp:99
An error handling class.
Definition Status.h:118
A class that represents a running process on the host machine.