2010-06-09 00:52:24 +08:00
|
|
|
//===-- StreamFile.cpp ------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/Core/StreamFile.h"
|
|
|
|
|
|
|
|
// C Includes
|
2011-02-09 09:08:52 +08:00
|
|
|
#include <stdio.h>
|
2010-06-09 00:52:24 +08:00
|
|
|
// C++ Includes
|
|
|
|
// Other libraries and framework includes
|
|
|
|
// Project includes
|
2011-02-09 09:08:52 +08:00
|
|
|
#include "lldb/Core/Error.h"
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// StreamFile constructor
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
StreamFile::StreamFile () :
|
|
|
|
Stream (),
|
2011-02-09 09:08:52 +08:00
|
|
|
m_file ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-02-09 09:08:52 +08:00
|
|
|
StreamFile::StreamFile (uint32_t flags, uint32_t addr_size, ByteOrder byte_order) :
|
2010-06-09 00:52:24 +08:00
|
|
|
Stream (flags, addr_size, byte_order),
|
2011-02-09 09:08:52 +08:00
|
|
|
m_file ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-02-09 09:08:52 +08:00
|
|
|
StreamFile::StreamFile (int fd, bool transfer_ownership) :
|
2010-06-09 00:52:24 +08:00
|
|
|
Stream (),
|
2011-02-09 09:08:52 +08:00
|
|
|
m_file (fd, transfer_ownership)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-02-09 09:08:52 +08:00
|
|
|
StreamFile::StreamFile (FILE *fh, bool transfer_ownership) :
|
|
|
|
Stream (),
|
|
|
|
m_file (fh, transfer_ownership)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-02-09 09:08:52 +08:00
|
|
|
StreamFile::StreamFile (const char *path) :
|
2010-06-09 00:52:24 +08:00
|
|
|
Stream (),
|
2013-11-21 05:07:01 +08:00
|
|
|
m_file (path, File::eOpenOptionWrite | File::eOpenOptionCanCreate, lldb::eFilePermissionsFileDefault)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
StreamFile::~StreamFile()
|
|
|
|
{
|
2011-02-05 14:41:57 +08:00
|
|
|
}
|
2011-02-05 14:37:53 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
void
|
|
|
|
StreamFile::Flush ()
|
|
|
|
{
|
2011-02-09 09:08:52 +08:00
|
|
|
m_file.Flush();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2013-01-26 02:06:21 +08:00
|
|
|
size_t
|
2010-06-09 00:52:24 +08:00
|
|
|
StreamFile::Write (const void *s, size_t length)
|
|
|
|
{
|
2011-02-09 09:08:52 +08:00
|
|
|
m_file.Write (s, length);
|
|
|
|
return length;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|