OSDN Git Service

Add WinMergePluginBase.h (2)
[winmerge-jp/winmerge-jp.git] / Src / 7zCommon.h
1 #pragma once
2
3 #define DllBuild_Merge7z 10 // Minimum DllBuild of Merge7z plugin required
4
5 // We include dllpstub.h for Merge7z.h
6 // Merge7z::Proxy embeds a DLLPSTUB
7 #include <list>
8 #include <map>
9 #include <PropIdl.h>
10 #include "dllpstub.h"
11 #include "../ArchiveSupport/Merge7z/Merge7z.h"
12 #include "paths.h"
13
14 class CDirView;
15 class CListCtrl;
16 class DIFFITEM;
17
18 extern __declspec(thread) Merge7z::Proxy Merge7z;
19
20 bool IsArchiveFile(const String&);
21 Merge7z::Format *ArchiveGuessFormat(const String&);
22
23 /**
24  * @brief temp path context
25  */
26 class CTempPathContext
27 {
28 public:
29         CTempPathContext *m_pParent;
30         String m_strDisplayRoot[3];
31         String m_strRoot[3];
32         CTempPathContext *DeleteHead();
33         void Swap(int idx1, int idx2);
34 };
35
36 /**
37  * @brief Merge7z::DirItemEnumerator to compress a single item.
38  */
39 class SingleItemEnumerator : public Merge7z::DirItemEnumerator
40 {
41         LPCTSTR FullPath;
42         LPCTSTR Name;
43 public:
44         virtual UINT Open();
45         virtual Merge7z::Envelope *Enum(Item &);
46         SingleItemEnumerator(LPCTSTR path, LPCTSTR FullPath, LPCTSTR Name = _T(""));
47 };
48
49 /**
50  * @brief Merge7z::DirItemEnumerator to compress items from DirView.
51  */
52 class DirItemEnumerator : public Merge7z::DirItemEnumerator
53 {
54 private:
55         CDirView *m_pView;
56         int m_nFlags;
57         int m_nIndex;
58         typedef CListCtrl *pView;
59         struct Envelope : public Merge7z::Envelope
60         {
61                 String Name;
62                 String FullPath;
63                 virtual void Free()
64                 {
65                         delete this;
66                 }
67         };
68         std::list<String> m_rgFolderPrefix;
69         std::list<String>::iterator m_curFolderPrefix;
70         String m_strFolderPrefix;
71         int m_index;
72         std::map<String, void *> m_rgImpliedFolders[3];
73 //      helper methods
74         const DIFFITEM &Next();
75         bool MultiStepCompressArchive(LPCTSTR);
76 public:
77         enum
78         {
79                 Left = 0x00,
80                 Middle = 0x10,
81                 Right = 0x20,
82                 Original = 0x40,
83                 Altered = 0x80,
84                 DiffsOnly = 0x100,
85                 BalanceFolders = 0x200
86         };
87         DirItemEnumerator(CDirView *, int);
88         virtual UINT Open();
89         virtual Merge7z::Envelope *Enum(Item &);
90         void CompressArchive(LPCTSTR = 0);
91 };
92
93 int NTAPI HasZipSupport();
94
95 struct DecompressResult
96 {
97         DecompressResult(const PathContext& files, CTempPathContext *pTempPathContext, paths::PATH_EXISTENCE pathsType) :
98                 files(files), pTempPathContext(pTempPathContext), pathsType(pathsType)
99         {
100         }
101         PathContext files;
102         CTempPathContext *pTempPathContext;
103         paths::PATH_EXISTENCE pathsType;
104 };
105 DecompressResult DecompressArchive(HWND hWnd, const PathContext& infiles);