TemporaryFile.h
1//-*-C++-*-
2/***************************************************************************
3 *
4 * Copyright (C) 2006 by Willem van Straten
5 * Licensed under the Academic Free License version 2.1
6 *
7 ***************************************************************************/
8
9// psrchive/Util/genutil/TemporaryFile.h
10
11#ifndef __TemporaryFile_h
12#define __TemporaryFile_h
13
14#include "Reference.h"
15
16#include <string>
17#include <set>
18
21{
22
23 public:
24
26 static bool abort;
27
29 TemporaryFile (const std::string& basename);
30
33
35 void close ();
36
38 void unlink ();
39
41 void remove ();
42
44 int get_fd () const { return fd; }
45
47 std::string get_filename () const { return filename; }
48
50 void set_removed (bool flag = true) { unlinked = flag; }
51
52 private:
53
55 std::string filename;
56
58 int fd;
59
61 bool unlinked;
62
64 static void install_signal_handler ();
65
67 static bool signal_handler_installed;
68
70 static void signal_handler (int);
71
72};
73
74#endif
75
Manages Reference::To references to the instance.
Definition ReferenceAble.h:35
std::string get_filename() const
Get the name of the temporary file.
Definition TemporaryFile.h:47
void remove()
Remove the temporary file (close and unlink)
Definition TemporaryFile.C:165
int get_fd() const
Get the file descriptor of the temporary file.
Definition TemporaryFile.h:44
static bool abort
Abort after processing any signals.
Definition TemporaryFile.h:26
~TemporaryFile()
Close and remove the temporary file.
Definition TemporaryFile.C:138
void unlink()
Unlink the temporary file.
Definition TemporaryFile.C:171
void set_removed(bool flag=true)
Set to true if the temporary file need not be removed.
Definition TemporaryFile.h:50
TemporaryFile(const std::string &basename)
Construct a temporary file with the specified basename.
Definition TemporaryFile.C:103
void close()
Close the temporary file.
Definition TemporaryFile.C:153

Generated using doxygen 1.14.0