{
close();
- // Don't assert that this is successful. The file could have
- // been removed by another process.
- unlink(name_.c_str());
+ if (!keep_)
+ {
+ // Don't assert that this is successful. The file could have
+ // been removed by another process.
+ unlink(name_.c_str());
+ }
}
void temp_file::close()
fd_ = -1;
}
}
+
+bool temp_file::keep_ = false;
+
+void temp_file::keep_all(bool keep)
+{
+ keep_ = keep;
+}
-// Copyright 2005 Ben Hutchings <ben@decadentplace.org.uk>.
+// Copyright 2005-6 Ben Hutchings <ben@decadentplace.org.uk>.
// See the file "COPYING" for licence details.
#ifndef INC_TEMP_FILE_HPP
int get_fd() const { return fd_; }
const std::string & get_name() const { return name_; }
+ static void keep_all(bool keep);
+
private:
int fd_;
std::string name_;
+
+ static bool keep_;
};
#endif // !INC_TEMP_FILE_HPP
{
argi += 2;
}
+ else if (std::strcmp(argv[argi], "--save-temps") == 0)
+ {
+ temp_file::keep_all(true);
+ argi += 1;
+ }
else if (argv[argi][0] == '-')
{
std::cerr << "Invalid option: " << argv[argi] << "\n";