forked from coolwanglu/pdf2htmlEX
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTmpFiles.cc
More file actions
56 lines (43 loc) · 1006 Bytes
/
Copy pathTmpFiles.cc
File metadata and controls
56 lines (43 loc) · 1006 Bytes
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
50
51
52
53
54
55
56
/*
* TmpFiles.cc
*
* Collect and clean-up temporary files
*
* implemented by WangLu
* split off by Filodej <philodej@gmail.com>
*/
#include <iostream>
#include "TmpFiles.h"
#include "Param.h"
using namespace std;
namespace pdf2htmlEX {
TmpFiles::TmpFiles( const Param& param )
: param( param )
{ }
TmpFiles::~TmpFiles()
{
clean();
}
void TmpFiles::add( const string & fn)
{
if(!param.clean_tmp)
return;
if(tmp_files.insert(fn).second && param.debug)
cerr << "Add new temporary file: " << fn << endl;
}
void TmpFiles::clean()
{
if(!param.clean_tmp)
return;
for(auto iter = tmp_files.begin(); iter != tmp_files.end(); ++iter)
{
const string & fn = *iter;
remove(fn.c_str());
if(param.debug)
cerr << "Remove temporary file: " << fn << endl;
}
remove(param.tmp_dir.c_str());
if(param.debug)
cerr << "Remove temporary directory: " << param.tmp_dir << endl;
}
} // namespace pdf2htmlEX