bes  Updated for version 3.17.4
BESHandlerUtil.h
1 // -*- mode: c++; c-basic-offset:4 -*-
2 
3 // This file is part of the BES, A C++ implementation of the OPeNDAP Data
4 // Access Protocol.
5 
6 // Copyright (c) 2016 OPeNDAP, Inc.
7 // Author: James Gallagher <jgallagher@opendap.org>
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
13 //
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
18 //
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 //
23 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
24 
25 #ifndef DAP_BESHANDLERUTIL_H_
26 #define DAP_BESHANDLERUTIL_H_
27 
28 #include <unistd.h>
29 
30 #include <vector>
31 #include <string>
32 
33 namespace bes {
34 
35 const std::string default_path_template = "TMP_DIR/opendapXXXXXX";
36 
46 private:
47  int d_fd;
48  std::vector<char> d_name;
49 
50 public:
58  TemporaryFile(default_path_template);
59  }
60 
61  TemporaryFile(const std::string &path_template);
62 
69  close(d_fd);
70  unlink(&d_name[0]);
71  }
72 
74  int get_fd() { return d_fd; }
75 
77  std::string get_name() { return &d_name[0]; }
78 };
79 
80 } // namespace bes
81 
82 #endif /* DAP_BESHANDLERUTIL_H_ */
std::string get_name()
Get a new temporary file.
~TemporaryFile()
Free the temporary file.
TemporaryFile()
Build a temporary file using a default template.