1//===--- Linux specialization of the File data structure ------------------===//
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#include "src/__support/File/file.h"
10
11namespace LIBC_NAMESPACE {
12
13FileIOResult linux_file_write(File *, const void *, size_t);
14FileIOResult linux_file_read(File *, void *, size_t);
15ErrorOr<long> linux_file_seek(File *, long, int);
16int linux_file_close(File *);
17
18class LinuxFile : public File {
19 int fd;
20
21public:
22 constexpr LinuxFile(int file_descriptor, uint8_t *buffer, size_t buffer_size,
23 int buffer_mode, bool owned, File::ModeFlags modeflags)
24 : File(&linux_file_write, &linux_file_read, &linux_file_seek,
25 &linux_file_close, buffer, buffer_size, buffer_mode, owned,
26 modeflags),
27 fd(file_descriptor) {}
28
29 int get_fd() const { return fd; }
30};
31
32} // namespace LIBC_NAMESPACE
33

source code of libc/src/__support/File/linux/file.h