-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTempFile.h
More file actions
49 lines (41 loc) · 1.08 KB
/
TempFile.h
File metadata and controls
49 lines (41 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* Copyright (C) Hauck Software Solutions - All Rights Reserved
* You may use, distribute and modify this code under the terms
* that changes to the code must be reported back the original
* author
*
* Company: Hauck Software Solutions
* Author: Thomas Hauck
* Email: Thomas@fam-hauck.de
*
*/
#ifndef TEMPFILE_H
#define TEMPFILE_H
#include <fstream>
#include <mutex>
#include <string>
using namespace std;
class TempFile
{
public:
friend wostream& operator<<(wostream&, TempFile&);
friend ostream& operator<<(ostream& os, TempFile& cTmpFile);
TempFile();
virtual ~TempFile();
void Open();
void Close();
void Flush();
void Write(const void* szBuf, streamsize nLen);
streamoff Read(unsigned char* szBuf, streamsize nLen);
void Rewind();
string GetFileName() noexcept;
streamoff GetFileLength();
fstream& operator() () noexcept;
private:
string m_strTmpFileName;
fstream m_theFile;
bool m_bIsFile;
static mutex s_mxFileName;
static string s_strTempDir;
static string s_strPreFix;
};
#endif // !TEMPFILE_H