klee
FileHandling.cpp
Go to the documentation of this file.
1//===-- FileHandling.cpp --------------------------------------------------===//
2//
3// The KLEE Symbolic Virtual Machine
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
10
11#include "klee/Config/Version.h"
12#include "klee/Config/config.h"
14
15#include "llvm/Support/FileSystem.h"
16
17#ifdef HAVE_ZLIB_H
19#endif
20
21namespace klee {
22
23std::unique_ptr<llvm::raw_fd_ostream>
24klee_open_output_file(const std::string &path, std::string &error) {
25 error.clear();
26 std::error_code ec;
27
28#if LLVM_VERSION_CODE >= LLVM_VERSION(7, 0)
29 auto f = std::make_unique<llvm::raw_fd_ostream>(path.c_str(), ec,
30 llvm::sys::fs::OF_None);
31#else
32 auto f = std::make_unique<llvm::raw_fd_ostream>(path.c_str(), ec,
33 llvm::sys::fs::F_None);
34#endif
35
36 if (ec)
37 error = ec.message();
38 if (!error.empty()) {
39 f.reset(nullptr);
40 }
41 return f;
42}
43
44#ifdef HAVE_ZLIB_H
45std::unique_ptr<llvm::raw_ostream>
46klee_open_compressed_output_file(const std::string &path, std::string &error) {
47 error.clear();
48 auto f = std::make_unique<compressed_fd_ostream>(path, error);
49 if (!error.empty()) {
50 f.reset(nullptr);
51 }
52 return f;
53}
54#endif
55}
Definition: main.cpp:291
std::unique_ptr< llvm::raw_fd_ostream > klee_open_output_file(const std::string &path, std::string &error)