1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-10-06 20:01:40 +00:00
pdf2htmlEX/src/HTMLRenderer/TmpFiles.cc
2012-11-29 16:55:20 +08:00

49 lines
868 B
C++

#include "TmpFiles.h"
#include "Param.h"
#include <iostream>
using namespace std;
namespace pdf2htmlEX {
TmpFiles::TmpFiles( Param const& 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