diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-03-25 15:24:13 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-03-25 15:24:13 +0000 |
| commit | 0a62857e4412d294712cfdf227fa38ae9ef371fe (patch) | |
| tree | a5e32cdc0fc69acf6b36ef84fb6a3f525f03ac14 /src/lib/util.cc | |
| parent | 68215e4e2dc313b74da7bde187917add138d3c9f (diff) | |
Add support for downloading Doremi server certificates.
Diffstat (limited to 'src/lib/util.cc')
| -rw-r--r-- | src/lib/util.cc | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/lib/util.cc b/src/lib/util.cc index 85c52b039..7a19790eb 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -1030,3 +1030,38 @@ divide_with_round (int64_t a, int64_t b) return a / b; } } + +ScopedTemporary::ScopedTemporary () + : _open (0) +{ + _file = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path (); +} + +ScopedTemporary::~ScopedTemporary () +{ + close (); + boost::system::error_code ec; + boost::filesystem::remove (_file, ec); +} + +char const * +ScopedTemporary::c_str () const +{ + return _file.string().c_str (); +} + +FILE* +ScopedTemporary::open (char const * params) +{ + _open = fopen (c_str(), params); + return _open; +} + +void +ScopedTemporary::close () +{ + if (_open) { + fclose (_open); + _open = 0; + } +} |
