edelib 2.1.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List

TempFile.h
1 /*
2 * $Id: TempFile.h 3385 2012-08-22 21:09:54Z karijes $
3 *
4 * Temporary file handler
5 * Copyright (c) 2005-2007 edelib authors
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #ifndef __EDELIB_TEMPFILE_H__
22 #define __EDELIB_TEMPFILE_H__
23
24 #include <stdio.h>
25 #include "String.h"
26
27 EDELIB_NS_BEGIN
28
41 class EDELIB_API TempFile {
42 private:
43 int fd;
44 int errno_err;
45 FILE *stream;
46 bool auto_del;
47 bool no_close;
48 String filename;
49
50 E_DISABLE_CLASS_COPY(TempFile)
51 public:
55 TempFile();
56
60 ~TempFile();
61
67 bool create(const char* prefix, int mode = 0600);
68
72 operator bool(void) const { return (errno_err == 0); }
73
77 void unlink(void);
78
82 bool close(void);
83
87 void set_auto_delete(bool v) { auto_del = v; }
88
92 void set_no_close(bool n) { no_close = n; }
93
97 FILE* fstream(void);
98
102 const char* name(void) const { return (filename.empty() ? NULL : filename.c_str()); }
103
107 int handle(void) const { return fd; }
108
112 int status(void) const { return errno_err; }
113 };
114
115 EDELIB_NS_END
116 #endif
edelib::TempFile::set_no_close
void set_no_close(bool n)
Definition: TempFile.h:92
edelib::String::empty
bool empty(void) const
Definition: String.h:298
edelib::TempFile::name
const char * name(void) const
Definition: TempFile.h:102
edelib::TempFile::set_auto_delete
void set_auto_delete(bool v)
Definition: TempFile.h:87
edelib::String::c_str
const char * c_str(void)
Definition: String.h:279
edelib::TempFile::handle
int handle(void) const
Definition: TempFile.h:107
edelib::TempFile
Temporary file class.
Definition: TempFile.h:41
E_DISABLE_CLASS_COPY
#define E_DISABLE_CLASS_COPY(klass)
Definition: edelib-global.h:161
edelib::TempFile::status
int status(void) const
Definition: TempFile.h:112
edelib::String
A (relatively simple) string implementation.
Definition: String.h:82