IO::File *Packer::tempfile()
{
+ FS::Path tmpdir;
+ const char *tmp_env = getenv("TMPDIR");
+ if(tmp_env)
+ tmpdir = tmp_env;
+ else
+ tmpdir = "/tmp";
+
for(unsigned i=0;; ++i)
{
try
{
- std::string filename = format("/tmp/mspdatatool.%d", i);
- /*filename.reserve(25);
- filename.append("/tmp/mspdatatool.");
- for(unsigned i=0; i<8; ++i)
- filename.append(rand());*/
- IO::File *file = new IO::File(filename, IO::M_RDWR, IO::File::C_NEW);
- FS::unlink(filename);
+ FS::Path filename = tmpdir/format("mspdatatool.%d", i);
+ IO::File *file = new IO::File(filename.str(), IO::M_RDWR, IO::File::C_NEW);
+ FS::unlink(filename.str());
return file;
}
catch(const IO::file_already_exists &)
IO::SeekOffset offset = in.tell();
bool raw = false;
DataFile::Parser parser(in, "-");
- while(!raw && !in.eof() && in.tell()<10240)
+ while(!raw && parser && in.tell()<10240)
{
try
{