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