1 // -*- mode: C++; -*-
2 #ifndef INCLUDED_TEMPORARY_FILE_DIRECTORY
3 #define INCLUDED_TEMPORARY_FILE_DIRECTORY
4 
5 #include <string>
6 
7 /**
8  * Provides services for allocating and reserving
9  * secure, temporary directories.
10  *
11  * @author Kai Vehmanen
12  */
13 class TEMPORARY_FILE_DIRECTORY {
14 
15  public:
16 
17   static const int max_temp_files = 512;
18 
19   TEMPORARY_FILE_DIRECTORY(void);
20   TEMPORARY_FILE_DIRECTORY(const std::string& dir);
21   ~TEMPORARY_FILE_DIRECTORY(void);
22 
23   void set_directory_prefix(const std::string& dir);
24   void reserve_directory(const std::string& nspace);
25   void release_directory(void);
26 
27   std::string get_directory_prefix(void) const;
28   std::string get_reserved_directory(void) const;
29   std::string create_filename(const std::string& prefix, const std::string& postfix);
30   bool is_valid(void) const;
31 
32  private:
33 
34   void check_validity(void);
35 
36   std::string tdir_rep;
37   std::string dirprefix_rep;
38   int tmp_index_rep;
39   bool valid_rep;
40 };
41 
42 #endif
43