1 //===-- StreamFile.cpp ------------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "lldb/Core/StreamFile.h" 11 #include "lldb/Host/FileSystem.h" 12 13 #include <stdio.h> 14 15 using namespace lldb; 16 using namespace lldb_private; 17 18 //---------------------------------------------------------------------- 19 // StreamFile constructor 20 //---------------------------------------------------------------------- 21 StreamFile::StreamFile() : Stream(), m_file() {} 22 23 StreamFile::StreamFile(uint32_t flags, uint32_t addr_size, ByteOrder byte_order) 24 : Stream(flags, addr_size, byte_order), m_file() {} 25 26 StreamFile::StreamFile(int fd, bool transfer_ownership) 27 : Stream(), m_file(fd, transfer_ownership) {} 28 29 StreamFile::StreamFile(FILE *fh, bool transfer_ownership) 30 : Stream(), m_file(fh, transfer_ownership) {} 31 32 StreamFile::StreamFile(const char *path) : Stream(), m_file() { 33 FileSystem::Instance().Open(m_file, FileSpec(path), 34 File::eOpenOptionWrite | 35 File::eOpenOptionCanCreate | 36 File::eOpenOptionCloseOnExec); 37 } 38 39 StreamFile::StreamFile(const char *path, uint32_t options, uint32_t permissions) 40 : Stream(), m_file() { 41 42 FileSystem::Instance().Open(m_file, FileSpec(path), options, permissions); 43 } 44 45 StreamFile::~StreamFile() {} 46 47 void StreamFile::Flush() { m_file.Flush(); } 48 49 size_t StreamFile::WriteImpl(const void *s, size_t length) { 50 m_file.Write(s, length); 51 return length; 52 } 53