tempfile.cpp 732 B

12345678910111213141516171819202122232425
  1. #include "tempfile.h"
  2. TTempFileHandle::TTempFileHandle()
  3. : TTempFile(MakeTempName())
  4. , TFile(CreateFile())
  5. {
  6. }
  7. TTempFileHandle::TTempFileHandle(const TString& fname)
  8. : TTempFile(fname)
  9. , TFile(CreateFile())
  10. {
  11. }
  12. TTempFileHandle TTempFileHandle::InCurrentDir(const TString& filePrefix, const TString& extension) {
  13. return TTempFileHandle(MakeTempName(".", filePrefix.c_str(), extension.c_str()));
  14. }
  15. TTempFileHandle TTempFileHandle::InDir(const TFsPath& dirPath, const TString& filePrefix, const TString& extension) {
  16. return TTempFileHandle(MakeTempName(dirPath.c_str(), filePrefix.c_str(), extension.c_str()));
  17. }
  18. TFile TTempFileHandle::CreateFile() const {
  19. return TFile(Name(), CreateAlways | RdWr);
  20. }