aboutsummaryrefslogtreecommitdiffstats
path: root/util/system/tempfile.cpp
blob: 534ccf9b268f2200470f3b35d1b76b6593b71705 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "tempfile.h"

TTempFileHandle::TTempFileHandle() 
    : TTempFile(MakeTempName()) 
    , TFile(CreateFile()) 
{ 
}

TTempFileHandle::TTempFileHandle(const TString& fname)
    : TTempFile(fname)
    , TFile(CreateFile())
{
}

TTempFileHandle TTempFileHandle::InCurrentDir(const TString& filePrefix, const TString& extension) { 
    return TTempFileHandle(MakeTempName(".", filePrefix.c_str(), extension.c_str())); 
}
 
TTempFileHandle TTempFileHandle::InDir(const TFsPath& dirPath, const TString& filePrefix, const TString& extension) { 
    return TTempFileHandle(MakeTempName(dirPath.c_str(), filePrefix.c_str(), extension.c_str())); 
} 
 
TFile TTempFileHandle::CreateFile() const { 
    return TFile(Name(), CreateAlways | RdWr); 
}