OSDN Git Service

Add Expand Different Subfolders menu item (#1964)
[winmerge-jp/winmerge-jp.git] / Src / TempFile.h
1 /**
2  *  @file TempFile.h
3  *
4  *  @brief Declaration of TempFile
5  */
6 #pragma once
7
8 #include <vector>
9 #include "UnicodeString.h"
10
11 /**
12  * @brief A simple temporary file holder class.
13  * This class creates and holds temporary file names. When instance
14  * gets destroyed, the temporary file is also deleted.
15  */
16 class TempFile
17 {
18 public:
19         TempFile() = default;
20         ~TempFile();
21         String Create(const String& prefix = _T(""), const String& ext = _T(""));
22         void Attach(const String& path) { Delete(); m_path = path; }
23         /**
24          * @brief Get temp file path (including filename).
25          * @return Full path to temp file.
26          */
27         const String& GetPath() const { return m_path; }
28         bool Delete();
29
30 private:
31         String m_path; /**< Temporary file path. */
32 };
33
34 /**
35  * @brief A simple temporary folder holder class.
36  * This class creates and holds temporary folder names. When instance
37  * gets destroyed, the temporary folder is also deleted.
38  */
39 class TempFolder
40 {
41 public:
42         TempFolder() {}
43         ~TempFolder();
44         String Create();
45         /**
46          * @brief Get temp folder path
47          * @return Full path to temp folder.
48          */
49         const String& GetPath() const { return m_path; }
50         bool Delete();
51
52 private:
53         String m_path; /**< Temporary folder path. */
54 };
55
56 void CleanupWMtemp();
57 bool ClearTempfolder(const String &pathName);