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 StreamFile::StreamFile (const char *path, 58 uint32_t options, 59 uint32_t permissions) : 60 Stream(), 61 m_file(path, options, permissions) 62 { 63 } 64 65 StreamFile::~StreamFile() 66 { 67 } 68 69 void 70 StreamFile::Flush () 71 { 72 m_file.Flush(); 73 } 74 75 size_t 76 StreamFile::Write (const void *s, size_t length) 77 { 78 m_file.Write (s, length); 79 return length; 80 } 81