Debian Codegraph @

CodeLite/clTempFile.hpp

raw
1 #ifndef CLTEMPFILE_HPP
2 #define CLTEMPFILE_HPP
3
4 #include "codelite_exports.h"
5 #include "fileutils.h"
6
7 #include <wx/filename.h>
8 #include <wx/string.h>
9
10 class WXDLLIMPEXP_CL clTempFile
11 {
12 wxFileName m_filename;
13 bool m_deleteOnDestruct = true;
14
15 public:
16 /// create a file in the default temp folder using the default values
17 clTempFile(const wxString& ext = "txt");
18
19 /// create a temp file in the provided folder using the given extension
20 clTempFile(const wxString& folder, const wxString& ext);
21
22 ~clTempFile();
23 /**
24 * @brief wite content to the temp file
25 */
26 bool Write(const wxString& content, wxMBConv& conv = wxConvUTF8);
27 /**
28 * @brief return the temp file path
29 */
30 const wxFileName& GetFileName() const { return m_filename; }
31
32 /**
33 * @brief return the tmp file full path. Wrapped with double quotes if spaces detected
34 */
35 wxString GetFullPath(bool wrapped_with_quotes = false) const;
36
37 /**
38 * @brief do not delete this file on destruct
39 */
40 void Persist();
41 };
42
43 #endif // CLTEMPFILE_HPP