Grassroots Infrastructure
The Grassroots Infrastructure is a suite of computing tools to help users and developers use scientific data infrastructure that can easily be interconnected.
blast/include/temp_file.hpp
Go to the documentation of this file.
1 /*
2 ** Copyright 2014-2016 The Earlham Institute
3 **
4 ** Licensed under the Apache License, Version 2.0 (the "License");
5 ** you may not use this file except in compliance with the License.
6 ** You may obtain a copy of the License at
7 **
8 ** http://www.apache.org/licenses/LICENSE-2.0
9 **
10 ** Unless required by applicable law or agreed to in writing, software
11 ** distributed under the License is distributed on an "AS IS" BASIS,
12 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 ** See the License for the specific language governing permissions and
14 ** limitations under the License.
15 */
16 
21 /*
22  * temp_file.hpp
23  *
24  * Created on: 22 Apr 2015
25  * Author: tyrrells
26  */
27 
28 #ifndef TEMP_FILE_HPP_
29 #define TEMP_FILE_HPP_
30 
31 #include <fstream>
32 #include <cstdio>
33 
34 #include "uuid_defs.h"
35 
36 #include "blast_service_api.h"
37 #include "memory_allocations.h"
38 
39 using namespace std;
40 
47 {
48 public:
49 
63  static TempFile *GetTempFile (const char *template_s, const bool temp_flag);
64 
77  static TempFile *GetTempFile (const char *working_dir_s, const uuid_t id, const char * const suffix_s);
78 
82  ~TempFile ();
83 
89  const char *GetFilename () const;
90 
99  bool Open (const char *mode_s);
100 
101 
108  int Close ();
109 
110 
118  bool Print (const char *arg_s);
119 
125  const char *GetData ();
126 
127 
131  void ClearData ();
132 
133 
140  bool IsOpen () const;
141 
142 private:
147  char *tf_name_s;
148 
154  MEM_FLAG tf_name_mem;
155 
160  FILE *tf_handle_f;
161 
166  char *tf_data_s;
167 
171  TempFile ();
172 };
173 
174 
175 #ifdef __cplusplus
176 extern "C"
177 {
178 #endif
179 
195 GRASSROOTS_UTIL_API char *GetTempFilenameBuffer (const char * const working_directory_s, const char * const prefix_s, const char * const temp_suffix_s);
196 
197 #ifdef __cplusplus
198 }
199 #endif
200 
201 
202 
203 #endif /* TEMP_FILE_HPP_ */
MEM_FLAG
MEM_FLAG
An enum specifying the particular status of a piece of dynamically allocated memory for a particular ...
Definition: memory_allocations.h:38
blast_service_api.h
uuid_defs.h
BLAST_SERVICE_LOCAL
#define BLAST_SERVICE_LOCAL
Definition: blast_service_api.h:48
TempFile
Create a temporary file to read and write data to.
Definition: blast/include/temp_file.hpp:46
memory_allocations.h
GRASSROOTS_UTIL_API
#define GRASSROOTS_UTIL_API
Definition: grassroots_util_library.h:47
uuid_t
Definition: windows_uuid.h:43