CBMC
tempfile.h
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module:
4
5
Author: Daniel Kroening
6
7
\*******************************************************************/
8
9
10
#ifndef CPROVER_UTIL_TEMPFILE_H
11
#define CPROVER_UTIL_TEMPFILE_H
12
13
#include <string>
14
15
// Returns an unused file name for a writeable temporary file,
16
// and makes sure it exists.
17
std::string
get_temporary_file
(
18
const
std::string &prefix,
19
const
std::string &suffix);
20
21
// The below deletes the temporary file upon destruction,
22
// cleaning up after you in case of exceptions.
23
class
temporary_filet
24
{
25
public
:
26
temporary_filet
(
27
const
std::string &prefix,
28
const
std::string &suffix):
29
name
(
get_temporary_file
(prefix, suffix))
30
{
31
}
32
33
// Using the copy constructor would delete the file twice.
34
temporary_filet
(
const
temporary_filet
&)=
delete
;
35
36
temporary_filet
(
temporary_filet
&&other)
37
{
38
name
.swap(other.name);
39
}
40
41
// get the name
42
std::string
operator()
()
const
43
{
44
return
name
;
45
}
46
47
// will delete the file
48
~temporary_filet
();
49
50
protected
:
51
std::string
name
;
52
};
53
54
#endif
// CPROVER_UTIL_TEMPFILE_H
temporary_filet
Definition:
tempfile.h:24
temporary_filet::temporary_filet
temporary_filet(temporary_filet &&other)
Definition:
tempfile.h:36
temporary_filet::temporary_filet
temporary_filet(const temporary_filet &)=delete
temporary_filet::name
std::string name
Definition:
tempfile.h:51
temporary_filet::temporary_filet
temporary_filet(const std::string &prefix, const std::string &suffix)
Definition:
tempfile.h:26
temporary_filet::operator()
std::string operator()() const
Definition:
tempfile.h:42
temporary_filet::~temporary_filet
~temporary_filet()
Definition:
tempfile.cpp:145
get_temporary_file
std::string get_temporary_file(const std::string &prefix, const std::string &suffix)
Substitute for mkstemps (OpenBSD standard) for Windows, where it is unavailable.
Definition:
tempfile.cpp:99
src
util
tempfile.h
Generated by
1.9.1