LLDB  mainline
StreamFile.cpp
Go to the documentation of this file.
1 //===-- StreamFile.cpp ------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "lldb/Core/StreamFile.h"
10 #include "lldb/Host/FileSystem.h"
11 
12 #include <stdio.h>
13 
14 using namespace lldb;
15 using namespace lldb_private;
16 
17 // StreamFile constructor
18 StreamFile::StreamFile() : Stream(), m_file() {}
19 
20 StreamFile::StreamFile(uint32_t flags, uint32_t addr_size, ByteOrder byte_order)
21  : Stream(flags, addr_size, byte_order), m_file() {}
22 
23 StreamFile::StreamFile(int fd, bool transfer_ownership)
24  : Stream(), m_file(fd, transfer_ownership) {}
25 
26 StreamFile::StreamFile(FILE *fh, bool transfer_ownership)
27  : Stream(), m_file(fh, transfer_ownership) {}
28 
29 StreamFile::StreamFile(const char *path) : Stream(), m_file() {
34 }
35 
36 StreamFile::StreamFile(const char *path, uint32_t options, uint32_t permissions)
37  : Stream(), m_file() {
38 
39  FileSystem::Instance().Open(m_file, FileSpec(path), options, permissions);
40 }
41 
43 
45 
46 size_t StreamFile::WriteImpl(const void *s, size_t length) {
47  m_file.Write(s, length);
48  return length;
49 }
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
void Flush() override
Flush the stream.
Definition: StreamFile.cpp:44
A file utility class.
Definition: FileSpec.h:55
static FileSystem & Instance()
Status Write(const void *buf, size_t &num_bytes) override
Write bytes to a file at the current file position.
Definition: File.cpp:394
Definition: SBAddress.h:15
Status Flush()
Flush the current stream.
Definition: File.cpp:301
size_t WriteImpl(const void *s, size_t length) override
Output character bytes to the stream.
Definition: StreamFile.cpp:46
int Open(const char *path, int flags, int mode)
Wraps ::open in a platform-independent way.