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 11 namespace LIBC_NAMESPACE { 12 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 *); 17 18 class LinuxFile : public File { 19 int fd; 20 21 public: LinuxFile(int file_descriptor,uint8_t * buffer,size_t buffer_size,int buffer_mode,bool owned,File::ModeFlags modeflags)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 get_fd()29 int get_fd() const { return fd; } 30 }; 31 32 } // namespace LIBC_NAMESPACE 33