1 // TortoiseSVN - a Windows shell extension for easy version control
3 // External Cache Copyright (C) 2005 - 2006, 2008 - TortoiseSVN
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.
21 #include "StatusCacheEntry.h"
26 * Holds the status for a folder and all files and folders directly inside
29 class CCachedDirectory
32 typedef std::map
<CTGitPath
, CCachedDirectory
*> CachedDirMap
;
33 typedef CachedDirMap::iterator ItDir
;
38 CCachedDirectory(const CTGitPath
& directoryPath
);
39 ~CCachedDirectory(void);
40 CStatusCacheEntry
GetStatusForMember(const CTGitPath
& path
, bool bRecursive
, bool bFetch
= true);
42 CStatusCacheEntry
GetOwnStatus(bool bRecursive
);
43 bool IsOwnStatusValid() const;
45 void RefreshStatus(bool bRecursive
);
46 void RefreshMostImportant();
47 BOOL
SaveToDisk(FILE * pFile
);
48 BOOL
LoadFromDisk(FILE * pFile
);
49 /// Get the current full status of this folder
50 git_wc_status_kind
GetCurrentFullStatus() {return m_currentFullStatus
;}
52 // static git_error_t* GetStatusCallback(void *baton, const char *path, git_wc_status2_t *status);
53 static BOOL
GetStatusCallback(const struct wgFile_s
*pFile
, void *pUserData
);
54 void AddEntry(const CTGitPath
& path
, const git_wc_status2_t
* pGitStatus
, DWORD validuntil
= 0);
55 CString
GetCacheKey(const CTGitPath
& path
);
56 CString
GetFullPathString(const CString
& cacheKey
);
57 CStatusCacheEntry
LookForItemInCache(const CTGitPath
& path
, bool &bFound
);
58 void UpdateChildDirectoryStatus(const CTGitPath
& childDir
, git_wc_status_kind childStatus
);
60 // Calculate the complete, composite status from ourselves, our files, and our descendants
61 git_wc_status_kind
CalculateRecursiveStatus();
63 // Update our composite status and deal with things if it's changed
64 void UpdateCurrentStatus();
68 CComAutoCriticalSection m_critSec
;
69 CComAutoCriticalSection m_critSecPath
;
71 CTGitPath m_currentStatusFetchingPath
;
72 DWORD m_currentStatusFetchingPathTicks
;
73 // The cache of files and directories within this directory
74 typedef std::map
<CString
, CStatusCacheEntry
> CacheEntryMap
;
75 CacheEntryMap m_entryCache
;
77 /// A vector if iterators to child directories - used to put-together recursive status
78 typedef std::map
<CTGitPath
, git_wc_status_kind
> ChildDirStatus
;
79 ChildDirStatus m_childDirectories
;
81 // The timestamp of the .git\index file. For an unversioned directory, this will be zero
82 __int64 m_indexFileTime
;
83 // The timestamp of the .SVN\props dir. For an unversioned directory, this will be zero
84 // __int64 m_propsFileTime;
86 // The path of the directory with this object looks after
87 CTGitPath m_directoryPath
;
89 // The status of THIS directory (not a composite of children or members)
90 CStatusCacheEntry m_ownStatus
;
92 // Our current fully recursive status
93 git_wc_status_kind m_currentFullStatus
;
94 bool m_bCurrentFullStatusValid
;
96 // The most important status from all our file entries
97 git_wc_status_kind m_mostImportantFileStatus
;
99 bool m_bRecursive
; // used in the status callback
100 friend class CGitStatusCache
;