1 //===--- Linux specialization of the File data structure ------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "src/__support/File/file.h"
11 namespace LIBC_NAMESPACE
{
13 FileIOResult
linux_file_write(File
*, const void *, size_t);
14 FileIOResult
linux_file_read(File
*, void *, size_t);
15 ErrorOr
<long> linux_file_seek(File
*, long, int);
16 int linux_file_close(File
*);
18 class LinuxFile
: public File
{
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
,
27 fd(file_descriptor
) {}
29 int get_fd() const { return fd
; }
32 } // namespace LIBC_NAMESPACE