Packer::Packer(DataTool &t):
tool(t),
- tmp_file(tempfile())
+ tmp_file(tempfile(tmp_path))
{ }
-IO::BufferedFile *Packer::tempfile()
+IO::BufferedFile *Packer::tempfile(FS::Path &out_fn)
{
FS::Path tmpdir = FS::get_temp_dir();
{
FS::Path filename = tmpdir/format("mspdatatool.%d", i);
IO::BufferedFile *file = new IO::BufferedFile(filename.str(), IO::M_RDWR, IO::File::C_NEW);
- FS::unlink(filename.str());
+ out_fn = filename;
return file;
}
catch(const IO::file_already_exists &)
Packer::~Packer()
{
delete tmp_file;
+ FS::unlink(tmp_path);
}
void Packer::pack_file(const string &fn)
typedef std::list<Object> ObjectList;
DataTool &tool;
+ Msp::FS::Path tmp_path;
Msp::IO::BufferedFile *tmp_file = nullptr;
std::list<Msp::DataFile::Statement> directory;
unsigned dir_alloc = 0;
public:
Packer(DataTool &);
private:
- static Msp::IO::BufferedFile *tempfile();
+ static Msp::IO::BufferedFile *tempfile(Msp::FS::Path &);
public:
~Packer();