1 //===-- TempFile.cpp ------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "llvm/Support/FileSystem.h"
12 using namespace lldb_fuzzer
;
15 TempFile::~TempFile() {
17 sys::fs::remove(m_path
.str(), true);
20 std::unique_ptr
<TempFile
> TempFile::Create(uint8_t *data
, size_t size
) {
22 std::unique_ptr
<TempFile
> temp_file
= std::make_unique
<TempFile
>();
23 std::error_code ec
= sys::fs::createTemporaryFile("lldb-fuzzer", "input", fd
,
28 raw_fd_ostream
os(fd
, true);
29 os
.write(reinterpret_cast<const char *>(data
), size
);