2014-05-13 07:59:33 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <array>
|
|
|
|
#include <cstdio>
|
|
|
|
#include <string>
|
|
|
|
|
2015-11-01 22:47:52 +08:00
|
|
|
#include <detail/include_windows.hpp>
|
2015-11-03 21:46:40 +08:00
|
|
|
#include <helpers/path_helper.hpp>
|
2014-05-20 08:47:15 +08:00
|
|
|
|
2016-08-03 12:12:18 +08:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
static std::string create_temporary_filename()
|
2014-05-13 07:59:33 +08:00
|
|
|
{
|
2016-11-20 08:41:21 +08:00
|
|
|
return "temp.xlsx";
|
2014-05-15 10:07:23 +08:00
|
|
|
}
|
2014-05-13 07:59:33 +08:00
|
|
|
|
2016-08-03 12:12:18 +08:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
class temporary_file
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
temporary_file() : path_(create_temporary_filename())
|
2014-05-13 07:59:33 +08:00
|
|
|
{
|
2016-08-03 12:12:18 +08:00
|
|
|
if(path_.exists())
|
2015-10-15 00:21:18 +08:00
|
|
|
{
|
2016-08-12 12:22:14 +08:00
|
|
|
std::remove(path_.string().c_str());
|
2015-10-15 00:21:18 +08:00
|
|
|
}
|
2014-05-13 07:59:33 +08:00
|
|
|
}
|
|
|
|
|
2016-07-21 07:54:24 +08:00
|
|
|
~temporary_file()
|
2014-05-13 07:59:33 +08:00
|
|
|
{
|
2016-08-12 12:22:14 +08:00
|
|
|
std::remove(path_.string().c_str());
|
2014-05-13 07:59:33 +08:00
|
|
|
}
|
|
|
|
|
2016-08-03 12:12:18 +08:00
|
|
|
xlnt::path get_path() const { return path_; }
|
2014-05-13 07:59:33 +08:00
|
|
|
|
|
|
|
private:
|
2016-08-03 12:12:18 +08:00
|
|
|
const xlnt::path path_;
|
2014-05-15 10:07:23 +08:00
|
|
|
};
|