Disable warnings and drop prebuild scripts
[TortoiseGit.git] / src / TortoiseProc / gitlogcache.h
blob6ac969fe2a055cf1cb7c1c37e33ec1698b0657ce
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2012 - TortoiseGit
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #pragma once
21 #include "Git.h"
22 #include "TGitPath.h"
23 #include "GitRev.h"
24 #include "GitHash.h"
26 #define LOG_INDEX_MAGIC 0x88AA5566
27 #define LOG_DATA_MAGIC 0x99BB0FFF
28 #define LOG_DATA_ITEM_MAGIC 0x0FCC9ACC
29 #define LOG_DATA_FILE_MAGIC 0x19EE9DFF
30 #define LOG_INDEX_VERSION 0xF
32 #pragma pack (1)
33 struct SLogCacheIndexHeader
35 DWORD m_Magic;
36 DWORD m_Version;
37 DWORD m_ItemCount;
40 struct SLogCacheIndexItem
42 CGitHash m_Hash;
43 ULONGLONG m_Offset;
46 struct SLogCacheIndexFile
48 struct SLogCacheIndexHeader m_Header;
49 struct SLogCacheIndexItem m_Item[1]; //dynmatic size
52 struct SLogCacheRevFileHeader
54 DWORD m_Magic;
55 DWORD m_Version;
56 DWORD m_Action;
57 DWORD m_Stage;
58 DWORD m_ParentNo;
59 DWORD m_Add;
60 DWORD m_Del;
61 DWORD m_FileNameSize;
62 DWORD m_OldFileNameSize;
63 TCHAR m_FileName[1];
65 # pragma pack ()
67 struct SLogCacheRevItemHeader
69 DWORD m_Magic;
70 DWORD m_Version;
71 DWORD m_FileCount;
74 struct SLogCacheDataFileHeader
76 DWORD m_Magic;
77 DWORD m_Version;
80 class CGitHashMap:public std::map<CGitHash,GitRev>
82 public:
83 bool IsExist(CGitHash &hash)
85 return find(hash) != end();
89 #define INDEX_FILE_NAME _T("tortoisegit.index")
90 #define DATA_FILE_NAME _T("tortoisegit.data")
91 #define LOCK_FILE_NAME _T("tortoisegit.lock")
94 class CLogCache
96 public:
98 protected:
99 HANDLE m_IndexFile;
100 HANDLE m_IndexFileMap;
101 SLogCacheIndexFile *m_pCacheIndex;
105 HANDLE m_DataFile;
106 HANDLE m_DataFileMap;
107 BYTE *m_pCacheData;
108 DWORD m_DataFileLength;
110 void CloseDataHandles();
111 void CloseIndexHandles();
112 void Sort();
114 BOOL CheckHeader(SLogCacheIndexHeader *header)
116 __try
118 if(header->m_Magic != LOG_INDEX_MAGIC)
119 return FALSE;
121 if(header->m_Version != LOG_INDEX_VERSION)
122 return FALSE;
124 return TRUE;
126 __finally
129 return FALSE;
132 BOOL CheckHeader(SLogCacheRevFileHeader *header)
134 __try
136 if(header->m_Magic != LOG_DATA_FILE_MAGIC)
137 return FALSE;
139 if(header->m_Version != LOG_INDEX_VERSION)
140 return FALSE;
142 return TRUE;
144 __finally
147 return FALSE;
150 BOOL CheckHeader(SLogCacheRevItemHeader *header)
152 __try
154 if(header->m_Magic != LOG_DATA_ITEM_MAGIC)
155 return FALSE;
157 if(header->m_Version != LOG_INDEX_VERSION)
158 return FALSE;
160 return TRUE;
162 __finally
165 return FALSE;
168 BOOL CheckHeader(SLogCacheDataFileHeader *header)
170 __try
172 if(header->m_Magic != LOG_DATA_MAGIC)
173 return FALSE;
175 if(header->m_Version != LOG_INDEX_VERSION)
176 return FALSE;
178 return TRUE;
180 __finally
183 return FALSE;
186 int SaveOneItem(GitRev &Rev, LONG offset);
188 CString m_GitDir;
189 int RebuildCacheFile();
191 public:
192 CLogCache();
193 ~CLogCache();
194 int FetchCacheIndex(CString GitDir);
195 int LoadOneItem(GitRev &Rev,ULONGLONG offset);
196 ULONGLONG GetOffset(CGitHash &hash, SLogCacheIndexFile *pData =NULL);
198 CGitHashMap m_HashMap;
200 GitRev * GetCacheData(CGitHash &Rev);
201 int AddCacheEntry(GitRev &Rev);
202 int SaveCache();
204 int ClearAllParent();