1 //===-- StreamFile.cpp ------------------------------------------*- C++ -*-===// 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 "lldb/Core/StreamFile.h" 10 #include "lldb/Host/FileSystem.h" 11 12 #include <stdio.h> 13 14 using namespace lldb; 15 using namespace lldb_private; 16 17 // StreamFile constructor 18 StreamFile::StreamFile() : Stream(), m_file() {} 19 20 StreamFile::StreamFile(uint32_t flags, uint32_t addr_size, ByteOrder byte_order) 21 : Stream(flags, addr_size, byte_order), m_file() {} 22 23 StreamFile::StreamFile(int fd, bool transfer_ownership) 24 : Stream(), m_file(fd, transfer_ownership) {} 25 26 StreamFile::StreamFile(FILE *fh, bool transfer_ownership) 27 : Stream(), m_file(fh, transfer_ownership) {} 28 29 StreamFile::StreamFile(const char *path) : Stream(), m_file() { 30 FileSystem::Instance().Open(m_file, FileSpec(path), 31 File::eOpenOptionWrite | 32 File::eOpenOptionCanCreate | 33 File::eOpenOptionCloseOnExec); 34 } 35 36 StreamFile::StreamFile(const char *path, uint32_t options, uint32_t permissions) 37 : Stream(), m_file() { 38 39 FileSystem::Instance().Open(m_file, FileSpec(path), options, permissions); 40 } 41 42 StreamFile::~StreamFile() {} 43 44 void StreamFile::Flush() { m_file.Flush(); } 45 46 size_t StreamFile::WriteImpl(const void *s, size_t length) { 47 m_file.Write(s, length); 48 return length; 49 } 50