TempFile.h
/*
* $Id: TempFile.h 3385 2012-08-22 21:09:54Z karijes $
*
* Temporary file handler
* Copyright (c) 2005-2007 edelib authors
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __EDELIB_TEMPFILE_H__
#define __EDELIB_TEMPFILE_H__
#include <stdio.h>
#include "String.h"
EDELIB_NS_BEGIN
class EDELIB_API TempFile {
private:
int fd;
int errno_err;
FILE *stream;
bool auto_del;
bool no_close;
String filename;
E_DISABLE_CLASS_COPY(TempFile)
public:
TempFile();
~TempFile();
bool create(const char* prefix, int mode = 0600);
operator bool(void) const { return (errno_err == 0); }
void unlink(void);
bool close(void);
void set_auto_delete(bool v) { auto_del = v; }
void set_no_close(bool n) { no_close = n; }
FILE* fstream(void);
const char* name(void) const { return (filename.empty() ? NULL : filename.c_str()); }
int handle(void) const { return fd; }
int status(void) const { return errno_err; }
};
EDELIB_NS_END
#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