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 12 // C Includes 13 #include <stdio.h> 14 // C++ Includes 15 // Other libraries and framework includes 16 // Project includes 17 #include "lldb/Core/Error.h" 18 19 20 using namespace lldb; 21 using namespace lldb_private; 22 23 //---------------------------------------------------------------------- 24 // StreamFile constructor 25 //---------------------------------------------------------------------- 26 StreamFile::StreamFile () : 27 Stream (), 28 m_file () 29 { 30 } 31 32 StreamFile::StreamFile (uint32_t flags, uint32_t addr_size, ByteOrder byte_order) : 33 Stream (flags, addr_size, byte_order), 34 m_file () 35 { 36 } 37 38 StreamFile::StreamFile (int fd, bool transfer_ownership) : 39 Stream (), 40 m_file (fd, transfer_ownership) 41 { 42 } 43 44 StreamFile::StreamFile (FILE *fh, bool transfer_ownership) : 45 Stream (), 46 m_file (fh, transfer_ownership) 47 { 48 } 49 50 StreamFile::StreamFile (const char *path) : 51 Stream (), 52 m_file (path, File::eOpenOptionWrite | File::eOpenOptionCanCreate | File::eOpenOptionCloseOnExec, 53 lldb::eFilePermissionsFileDefault) 54 { 55 } 56 57 58 StreamFile::~StreamFile() 59 { 60 } 61 62 void 63 StreamFile::Flush () 64 { 65 m_file.Flush(); 66 } 67 68 size_t 69 StreamFile::Write (const void *s, size_t length) 70 { 71 m_file.Write (s, length); 72 return length; 73 } 74