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