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