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