| 1 |
#include "clTempFile.hpp" |
| 2 |
|
| 3 |
#include "cl_standard_paths.h" |
| 4 |
|
| 5 |
clTempFile::clTempFile(const wxString& ext) |
| 6 |
{ |
| 7 |
wxFileName::Mkdir(clStandardPaths::Get().GetTempDir(), wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL); |
| 8 |
m_filename = FileUtils::CreateTempFileName(clStandardPaths::Get().GetTempDir(), "cltmp", ext); |
| 9 |
} |
| 10 |
|
| 11 |
clTempFile::clTempFile(const wxString& folder, const wxString& ext) |
| 12 |
{ |
| 13 |
m_filename = FileUtils::CreateTempFileName(folder, "cltmp", ext); |
| 14 |
} |
| 15 |
|
| 16 |
clTempFile::~clTempFile() |
| 17 |
{ |
| 18 |
if(m_deleteOnDestruct) { |
| 19 |
FileUtils::RemoveFile(m_filename); |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
bool clTempFile::Write(const wxString& content, wxMBConv& conv) |
| 24 |
{ |
| 25 |
return FileUtils::WriteFileContent(GetFileName(), content, conv); |
| 26 |
} |
| 27 |
|
| 28 |
wxString clTempFile::GetFullPath(bool wrapped_with_quotes) const |
| 29 |
{ |
| 30 |
wxString fullpath = GetFileName().GetFullPath(); |
| 31 |
if(fullpath.Contains(" ")) { |
| 32 |
fullpath.Prepend("\"").Append("\""); |
| 33 |
} |
| 34 |
return fullpath; |
| 35 |
} |
| 36 |
|
| 37 |
void clTempFile::Persist() { m_deleteOnDestruct = false; } |