Reduce variable scope
[TortoiseGit.git] / src / TortoiseShell / ShellCache.h
blobc2fe48beb5eb0884120a72f8a5f2b1e32990377d
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2012-2013 - TortoiseGit
4 // Copyright (C) 2003-2008 - Stefan Kueng
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #pragma once
21 #include "registry.h"
22 #include "Globals.h"
23 #include "GitAdminDir.h"
24 #include "Git.h"
26 #define REGISTRYTIMEOUT 2000
27 #define EXCLUDELISTTIMEOUT 5000
28 #define ADMINDIRTIMEOUT 10000
29 #define DRIVETYPETIMEOUT 300000 // 5 min
30 #define NUMBERFMTTIMEOUT 300000
31 #define MENUTIMEOUT 100
33 #define DEFAULTMENUTOPENTRIES MENUSYNC|MENUCREATEREPOS|MENUCLONE|MENUCOMMIT
34 #define DEFAULTMENUEXTENTRIES MENUSVNIGNORE|MENUREFLOG|MENUREFBROWSE|MENUSTASHAPPLY|MENUSUBSYNC
36 typedef CComCritSecLock<CComCriticalSection> Locker;
38 /**
39 * \ingroup TortoiseShell
40 * Helper class which caches access to the registry. Also provides helper methods
41 * for checks against the settings stored in the registry.
43 class ShellCache
45 public:
46 enum CacheType
48 none,
49 exe,
50 dll,
51 dllFull,// same as dll except it uses commandline git tool with all status modes supported
53 ShellCache()
55 cachetype = CRegStdDWORD(_T("Software\\TortoiseGit\\CacheType"), GetSystemMetrics(SM_REMOTESESSION) ? dll : exe);
56 showrecursive = CRegStdDWORD(_T("Software\\TortoiseGit\\RecursiveOverlay"), TRUE);
57 folderoverlay = CRegStdDWORD(_T("Software\\TortoiseGit\\FolderOverlay"), TRUE);
58 driveremote = CRegStdDWORD(_T("Software\\TortoiseGit\\DriveMaskRemote"));
59 drivefixed = CRegStdDWORD(_T("Software\\TortoiseGit\\DriveMaskFixed"), TRUE);
60 drivecdrom = CRegStdDWORD(_T("Software\\TortoiseGit\\DriveMaskCDROM"));
61 driveremove = CRegStdDWORD(_T("Software\\TortoiseGit\\DriveMaskRemovable"));
62 drivefloppy = CRegStdDWORD(_T("Software\\TortoiseGit\\DriveMaskFloppy"));
63 driveram = CRegStdDWORD(_T("Software\\TortoiseGit\\DriveMaskRAM"));
64 driveunknown = CRegStdDWORD(_T("Software\\TortoiseGit\\DriveMaskUnknown"));
65 shellmenuaccelerators = CRegStdDWORD(_T("Software\\TortoiseGit\\ShellMenuAccelerators"), TRUE);
66 excludelist = CRegStdString(_T("Software\\TortoiseGit\\OverlayExcludeList"));
67 includelist = CRegStdString(_T("Software\\TortoiseGit\\OverlayIncludeList"));
68 simplecontext = CRegStdDWORD(_T("Software\\TortoiseGit\\SimpleContext"), FALSE);
69 unversionedasmodified = CRegStdDWORD(_T("Software\\TortoiseGit\\UnversionedAsModified"), FALSE);
70 hidemenusforunversioneditems = CRegStdDWORD(_T("Software\\TortoiseGit\\HideMenusForUnversionedItems"), FALSE);
71 showunversionedoverlay = CRegStdDWORD(_T("Software\\TortoiseGit\\ShowUnversionedOverlay"), TRUE);
72 showignoredoverlay = CRegStdDWORD(_T("Software\\TortoiseGit\\ShowIgnoredOverlay"), TRUE);
73 getlocktop = CRegStdDWORD(_T("Software\\TortoiseGit\\GetLockTop"), TRUE);
74 excludedasnormal = CRegStdDWORD(_T("Software\\TortoiseGit\\ShowExcludedAsNormal"), TRUE);
75 cachetypeticker = GetTickCount();
76 recursiveticker = cachetypeticker;
77 folderoverlayticker = cachetypeticker;
78 driveticker = cachetypeticker;
79 drivetypeticker = cachetypeticker;
80 langticker = cachetypeticker;
81 columnrevformatticker = cachetypeticker;
82 excludelistticker = cachetypeticker;
83 includelistticker = cachetypeticker;
84 simplecontextticker = cachetypeticker;
85 shellmenuacceleratorsticker = cachetypeticker;
86 unversionedasmodifiedticker = cachetypeticker;
87 showunversionedoverlayticker = cachetypeticker;
88 showignoredoverlayticker = cachetypeticker;
89 admindirticker = cachetypeticker;
90 columnseverywhereticker = cachetypeticker;
91 getlocktopticker = cachetypeticker;
92 excludedasnormalticker = cachetypeticker;
93 hidemenusforunversioneditemsticker = cachetypeticker;
94 excontextticker = cachetypeticker;
96 unsigned __int64 entries = (DEFAULTMENUTOPENTRIES);
97 menulayoutlow = CRegStdDWORD(_T("Software\\TortoiseGit\\ContextMenuEntries"), entries&0xFFFFFFFF);
98 menulayouthigh = CRegStdDWORD(_T("Software\\TortoiseGit\\ContextMenuEntrieshigh"), entries>>32);
100 unsigned __int64 ext = (DEFAULTMENUEXTENTRIES);
101 menuextlow = CRegStdDWORD(_T("Software\\TortoiseGit\\ContextMenuExtEntriesLow"), ext&0xFFFFFFFF );
102 menuexthigh = CRegStdDWORD(_T("Software\\TortoiseGit\\ContextMenuExtEntriesHigh"), ext>>32 );
104 menumasklow_lm = CRegStdDWORD(_T("Software\\TortoiseGit\\ContextMenuEntriesMaskLow"), 0, FALSE, HKEY_LOCAL_MACHINE);
105 menumaskhigh_lm = CRegStdDWORD(_T("Software\\TortoiseGit\\ContextMenuEntriesMaskHigh"), 0, FALSE, HKEY_LOCAL_MACHINE);
106 menumasklow_cu = CRegStdDWORD(_T("Software\\TortoiseGit\\ContextMenuEntriesMaskLow"), 0);
107 menumaskhigh_cu = CRegStdDWORD(_T("Software\\TortoiseGit\\ContextMenuEntriesMaskHigh"), 0);
108 langid = CRegStdDWORD(_T("Software\\TortoiseGit\\LanguageID"), 1033);
109 blockstatus = CRegStdDWORD(_T("Software\\TortoiseGit\\BlockStatus"), 0);
110 columnseverywhere = CRegStdDWORD(_T("Software\\TortoiseGit\\ColumnsEveryWhere"), FALSE);
111 for (int i = 0; i < 27; ++i)
113 drivetypecache[i] = (UINT)-1;
115 // A: and B: are floppy disks
116 drivetypecache[0] = DRIVE_REMOVABLE;
117 drivetypecache[1] = DRIVE_REMOVABLE;
118 TCHAR szBuffer[5];
119 columnrevformatticker = GetTickCount();
120 SecureZeroMemory(&columnrevformat, sizeof(NUMBERFMT));
121 GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, &szDecSep[0], _countof(szDecSep));
122 GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, &szThousandsSep[0], _countof(szThousandsSep));
123 columnrevformat.lpDecimalSep = szDecSep;
124 columnrevformat.lpThousandSep = szThousandsSep;
125 GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SGROUPING, &szBuffer[0], _countof(szBuffer));
126 columnrevformat.Grouping = _ttoi(szBuffer);
127 GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_INEGNUMBER, &szBuffer[0], _countof(szBuffer));
128 columnrevformat.NegativeOrder = _ttoi(szBuffer);
129 sAdminDirCacheKey.reserve(MAX_PATH); // MAX_PATH as buffer reservation ok.
130 nocontextpaths = CRegStdString(_T("Software\\TortoiseGit\\NoContextPaths"), _T(""));
131 m_critSec.Init();
133 void ForceRefresh()
135 cachetype.read();
136 showrecursive.read();
137 folderoverlay.read();
138 driveremote.read();
139 drivefixed.read();
140 drivecdrom.read();
141 driveremove.read();
142 drivefloppy.read();
143 driveram.read();
144 driveunknown.read();
145 excludelist.read();
146 includelist.read();
147 simplecontext.read();
148 shellmenuaccelerators.read();
149 unversionedasmodified.read();
150 showunversionedoverlay.read();
151 showignoredoverlay.read();
152 excludedasnormal.read();
153 hidemenusforunversioneditems.read();
154 menulayoutlow.read();
155 menulayouthigh.read();
156 langid.read();
157 blockstatus.read();
158 columnseverywhere.read();
159 getlocktop.read();
160 menumasklow_lm.read();
161 menumaskhigh_lm.read();
162 menumasklow_cu.read();
163 menumaskhigh_cu.read();
164 nocontextpaths.read();
166 CacheType GetCacheType()
168 if ((GetTickCount() - REGISTRYTIMEOUT) > cachetypeticker)
170 cachetypeticker = GetTickCount();
171 cachetype.read();
173 return CacheType(DWORD((cachetype)));
175 DWORD BlockStatus()
177 if ((GetTickCount() - REGISTRYTIMEOUT) > blockstatusticker)
179 blockstatusticker = GetTickCount();
180 blockstatus.read();
182 return (blockstatus);
184 unsigned __int64 GetMenuLayout()
186 if ((GetTickCount() - REGISTRYTIMEOUT) > layoutticker)
188 layoutticker = GetTickCount();
189 menulayoutlow.read();
190 menulayouthigh.read();
192 unsigned __int64 temp = unsigned __int64(DWORD(menulayouthigh))<<32;
193 temp |= unsigned __int64(DWORD(menulayoutlow));
194 return temp;
197 unsigned __int64 GetMenuExt()
199 if ((GetTickCount() - REGISTRYTIMEOUT) > exticker)
201 exticker = GetTickCount();
202 menuextlow.read();
203 menuexthigh.read();
205 unsigned __int64 temp = unsigned __int64(DWORD(menuexthigh))<<32;
206 temp |= unsigned __int64(DWORD(menuextlow));
207 return temp;
210 unsigned __int64 GetMenuMask()
212 if ((GetTickCount() - REGISTRYTIMEOUT) > menumaskticker)
214 menumaskticker = GetTickCount();
215 menumasklow_lm.read();
216 menumaskhigh_lm.read();
217 menumasklow_cu.read();
218 menumaskhigh_cu.read();
220 DWORD low = (DWORD)menumasklow_lm | (DWORD)menumasklow_cu;
221 DWORD high = (DWORD)menumaskhigh_lm | (DWORD)menumaskhigh_cu;
222 unsigned __int64 temp = unsigned __int64(high)<<32;
223 temp |= unsigned __int64(low);
224 return temp;
226 BOOL IsRecursive()
228 if ((GetTickCount() - REGISTRYTIMEOUT)>recursiveticker)
230 recursiveticker = GetTickCount();
231 showrecursive.read();
233 return (showrecursive);
235 BOOL IsFolderOverlay()
237 if ((GetTickCount() - REGISTRYTIMEOUT)>folderoverlayticker)
239 folderoverlayticker = GetTickCount();
240 folderoverlay.read();
242 return (folderoverlay);
244 BOOL IsSimpleContext()
246 if ((GetTickCount() - REGISTRYTIMEOUT)>simplecontextticker)
248 simplecontextticker = GetTickCount();
249 simplecontext.read();
251 return (simplecontext!=0);
253 BOOL ShellCache::HasShellMenuAccelerators()
255 if ((GetTickCount() - shellmenuacceleratorsticker)>REGISTRYTIMEOUT)
257 shellmenuacceleratorsticker = GetTickCount();
258 shellmenuaccelerators.read();
260 return (shellmenuaccelerators!=0);
262 BOOL IsUnversionedAsModified()
264 if ((GetTickCount() - REGISTRYTIMEOUT)>unversionedasmodifiedticker)
266 unversionedasmodifiedticker = GetTickCount();
267 unversionedasmodified.read();
269 return (unversionedasmodified);
271 BOOL ShowUnversionedOverlay()
273 if ((GetTickCount() - REGISTRYTIMEOUT)>showunversionedoverlayticker)
275 showunversionedoverlayticker = GetTickCount();
276 showunversionedoverlay.read();
278 return (showunversionedoverlay);
280 BOOL ShowIgnoredOverlay()
282 if ((GetTickCount() - REGISTRYTIMEOUT)>showignoredoverlayticker)
284 showignoredoverlayticker = GetTickCount();
285 showignoredoverlay.read();
287 return (showignoredoverlay);
289 BOOL IsGetLockTop()
291 if ((GetTickCount() - REGISTRYTIMEOUT)>getlocktopticker)
293 getlocktopticker = GetTickCount();
294 getlocktop.read();
296 return (getlocktop);
298 BOOL ShowExcludedAsNormal()
300 if ((GetTickCount() - REGISTRYTIMEOUT)>excludedasnormalticker)
302 excludedasnormalticker = GetTickCount();
303 excludedasnormal.read();
305 return (excludedasnormal);
307 BOOL HideMenusForUnversionedItems()
309 if ((GetTickCount() - hidemenusforunversioneditemsticker)>REGISTRYTIMEOUT)
311 hidemenusforunversioneditemsticker = GetTickCount();
312 hidemenusforunversioneditems.read();
314 return (hidemenusforunversioneditems);
316 BOOL IsRemote()
318 DriveValid();
319 return (driveremote);
321 BOOL IsFixed()
323 DriveValid();
324 return (drivefixed);
326 BOOL IsCDRom()
328 DriveValid();
329 return (drivecdrom);
331 BOOL IsRemovable()
333 DriveValid();
334 return (driveremove);
336 BOOL IsRAM()
338 DriveValid();
339 return (driveram);
341 BOOL IsUnknown()
343 DriveValid();
344 return (driveunknown);
346 BOOL IsContextPathAllowed(LPCTSTR path)
348 Locker lock(m_critSec);
349 ExcludeContextValid();
350 for (std::vector<stdstring>::iterator I = excontextvector.begin(); I != excontextvector.end(); ++I)
352 if (I->empty())
353 continue;
354 if (I->size() && I->at(I->size()-1)=='*')
356 stdstring str = I->substr(0, I->size()-1);
357 if (_tcsnicmp(str.c_str(), path, str.size())==0)
358 return FALSE;
360 else if (_tcsicmp(I->c_str(), path)==0)
361 return FALSE;
363 return TRUE;
365 BOOL IsPathAllowed(LPCTSTR path)
367 Locker lock(m_critSec);
368 IncludeListValid();
369 for (std::vector<stdstring>::iterator I = invector.begin(); I != invector.end(); ++I)
371 if (I->empty())
372 continue;
373 if (I->at(I->size()-1)=='*')
375 stdstring str = I->substr(0, I->size()-1);
376 if (_tcsnicmp(str.c_str(), path, str.size())==0)
377 return TRUE;
378 if (!str.empty() && (str.at(str.size()-1) == '\\') && (_tcsnicmp(str.c_str(), path, str.size()-1)==0))
379 return TRUE;
381 else if (_tcsicmp(I->c_str(), path)==0)
382 return TRUE;
383 else if ((I->at(I->size()-1) == '\\') &&
384 ((_tcsnicmp(I->c_str(), path, I->size())==0) || (_tcsicmp(I->c_str(), path)==0)) )
385 return TRUE;
388 UINT drivetype = 0;
389 int drivenumber = PathGetDriveNumber(path);
390 if ((drivenumber >=0)&&(drivenumber < 25))
392 drivetype = drivetypecache[drivenumber];
393 if ((drivetype == -1)||((GetTickCount() - DRIVETYPETIMEOUT)>drivetypeticker))
395 if ((drivenumber == 0)||(drivenumber == 1))
396 drivetypecache[drivenumber] = DRIVE_REMOVABLE;
397 else
399 drivetypeticker = GetTickCount();
400 TCHAR pathbuf[MAX_PATH+4]; // MAX_PATH ok here. PathStripToRoot works with partial paths too.
401 _tcsncpy_s(pathbuf, MAX_PATH+4, path, MAX_PATH+3);
402 PathStripToRoot(pathbuf);
403 PathAddBackslash(pathbuf);
404 ATLTRACE2(_T("GetDriveType for %s, Drive %d\n"), pathbuf, drivenumber);
405 drivetype = GetDriveType(pathbuf);
406 drivetypecache[drivenumber] = drivetype;
410 else
412 TCHAR pathbuf[MAX_PATH+4]; // MAX_PATH ok here. PathIsUNCServer works with partial paths too.
413 _tcsncpy_s(pathbuf, MAX_PATH+4, path, MAX_PATH+3);
414 if (PathIsUNCServer(pathbuf))
415 drivetype = DRIVE_REMOTE;
416 else
418 PathStripToRoot(pathbuf);
419 PathAddBackslash(pathbuf);
420 if (_tcsncmp(pathbuf, drivetypepathcache, MAX_PATH-1)==0) // MAX_PATH ok.
421 drivetype = drivetypecache[26];
422 else
424 ATLTRACE2(_T("GetDriveType for %s\n"), pathbuf);
425 drivetype = GetDriveType(pathbuf);
426 drivetypecache[26] = drivetype;
427 _tcsncpy_s(drivetypepathcache, MAX_PATH, pathbuf, MAX_PATH); // MAX_PATH ok.
431 if ((drivetype == DRIVE_REMOVABLE)&&(!IsRemovable()))
432 return FALSE;
433 if ((drivetype == DRIVE_REMOVABLE)&&(drivefloppy == 0)&&((drivenumber==0)||(drivenumber==1)))
434 return FALSE;
435 if ((drivetype == DRIVE_FIXED)&&(!IsFixed()))
436 return FALSE;
437 if (((drivetype == DRIVE_REMOTE)||(drivetype == DRIVE_NO_ROOT_DIR))&&(!IsRemote()))
438 return FALSE;
439 if ((drivetype == DRIVE_CDROM)&&(!IsCDRom()))
440 return FALSE;
441 if ((drivetype == DRIVE_RAMDISK)&&(!IsRAM()))
442 return FALSE;
443 if ((drivetype == DRIVE_UNKNOWN)&&(IsUnknown()))
444 return FALSE;
446 ExcludeListValid();
447 for (std::vector<stdstring>::iterator I = exvector.begin(); I != exvector.end(); ++I)
449 if (I->empty())
450 continue;
451 if (I->size() && I->at(I->size()-1)=='*')
453 stdstring str = I->substr(0, I->size()-1);
454 if (_tcsnicmp(str.c_str(), path, str.size())==0)
455 return FALSE;
457 else if (_tcsicmp(I->c_str(), path)==0)
458 return FALSE;
460 return TRUE;
462 DWORD GetLangID()
464 if ((GetTickCount() - REGISTRYTIMEOUT) > langticker)
466 langticker = GetTickCount();
467 langid.read();
469 return (langid);
471 NUMBERFMT * GetNumberFmt()
473 if ((GetTickCount() - NUMBERFMTTIMEOUT) > columnrevformatticker)
475 TCHAR szBuffer[5];
476 columnrevformatticker = GetTickCount();
477 SecureZeroMemory(&columnrevformat, sizeof(NUMBERFMT));
478 GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, &szDecSep[0], _countof(szDecSep));
479 GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, &szThousandsSep[0], _countof(szThousandsSep));
480 columnrevformat.lpDecimalSep = szDecSep;
481 columnrevformat.lpThousandSep = szThousandsSep;
482 GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SGROUPING, &szBuffer[0], _countof(szBuffer));
483 columnrevformat.Grouping = _ttoi(szBuffer);
484 GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_INEGNUMBER, &szBuffer[0], _countof(szBuffer));
485 columnrevformat.NegativeOrder = _ttoi(szBuffer);
487 return &columnrevformat;
489 BOOL HasGITAdminDir(LPCTSTR path, BOOL bIsDir, CString *ProjectTopDir = NULL)
491 size_t len = _tcslen(path);
492 std::unique_ptr<TCHAR[]> buf(new TCHAR[len + 1]);
493 _tcscpy_s(buf.get(), len + 1, path);
494 if (! bIsDir)
496 TCHAR * ptr = _tcsrchr(buf.get(), '\\');
497 if (ptr != 0)
499 *ptr = 0;
502 if ((GetTickCount() - ADMINDIRTIMEOUT) < admindirticker)
504 std::map<stdstring, AdminDir_s>::iterator iter;
505 sAdminDirCacheKey.assign(buf.get());
506 if ((iter = admindircache.find(sAdminDirCacheKey)) != admindircache.end())
508 if (ProjectTopDir && iter->second.bHasAdminDir)
509 *ProjectTopDir = iter->second.sProjectRoot.c_str();
510 return iter->second.bHasAdminDir;
513 CString sProjectRoot;
514 BOOL hasAdminDir = g_GitAdminDir.HasAdminDir(buf.get(), true, &sProjectRoot);
515 admindirticker = GetTickCount();
516 Locker lock(m_critSec);
518 AdminDir_s &ad = admindircache[buf.get()];
519 ad.bHasAdminDir = hasAdminDir;
520 if (hasAdminDir)
522 ad.sProjectRoot.assign(sProjectRoot);
524 if (ProjectTopDir)
525 *ProjectTopDir = sProjectRoot;
528 return hasAdminDir;
530 bool IsColumnsEveryWhere()
532 if ((GetTickCount() - REGISTRYTIMEOUT) > columnseverywhereticker)
534 columnseverywhereticker = GetTickCount();
535 columnseverywhere.read();
537 return !!(DWORD)columnseverywhere;
539 private:
540 void DriveValid()
542 if ((GetTickCount() - REGISTRYTIMEOUT)>driveticker)
544 driveticker = GetTickCount();
545 driveremote.read();
546 drivefixed.read();
547 drivecdrom.read();
548 driveremove.read();
549 drivefloppy.read();
552 void ExcludeContextValid()
554 if ((GetTickCount() - EXCLUDELISTTIMEOUT)>excontextticker)
556 Locker lock(m_critSec);
557 excontextticker = GetTickCount();
558 nocontextpaths.read();
559 if (excludecontextstr.compare((stdstring)nocontextpaths)==0)
560 return;
561 excludecontextstr = (stdstring)nocontextpaths;
562 excontextvector.clear();
563 size_t pos = 0, pos_ant = 0;
564 pos = excludecontextstr.find(_T("\n"), pos_ant);
565 while (pos != stdstring::npos)
567 stdstring token = excludecontextstr.substr(pos_ant, pos-pos_ant);
568 excontextvector.push_back(token);
569 pos_ant = pos+1;
570 pos = excludecontextstr.find(_T("\n"), pos_ant);
572 if (!excludecontextstr.empty())
574 excontextvector.push_back(excludecontextstr.substr(pos_ant, excludecontextstr.size()-1));
576 excludecontextstr = (stdstring)nocontextpaths;
579 void ExcludeListValid()
581 if ((GetTickCount() - EXCLUDELISTTIMEOUT)>excludelistticker)
583 Locker lock(m_critSec);
584 excludelistticker = GetTickCount();
585 excludelist.read();
586 if (excludeliststr.compare((stdstring)excludelist)==0)
587 return;
588 excludeliststr = (stdstring)excludelist;
589 exvector.clear();
590 size_t pos = 0, pos_ant = 0;
591 pos = excludeliststr.find(_T("\n"), pos_ant);
592 while (pos != stdstring::npos)
594 stdstring token = excludeliststr.substr(pos_ant, pos-pos_ant);
595 exvector.push_back(token);
596 pos_ant = pos+1;
597 pos = excludeliststr.find(_T("\n"), pos_ant);
599 if (!excludeliststr.empty())
601 exvector.push_back(excludeliststr.substr(pos_ant, excludeliststr.size()-1));
603 excludeliststr = (stdstring)excludelist;
606 void IncludeListValid()
608 if ((GetTickCount() - EXCLUDELISTTIMEOUT)>includelistticker)
610 Locker lock(m_critSec);
611 includelistticker = GetTickCount();
612 includelist.read();
613 if (includeliststr.compare((stdstring)includelist)==0)
614 return;
615 includeliststr = (stdstring)includelist;
616 invector.clear();
617 size_t pos = 0, pos_ant = 0;
618 pos = includeliststr.find(_T("\n"), pos_ant);
619 while (pos != stdstring::npos)
621 stdstring token = includeliststr.substr(pos_ant, pos-pos_ant);
622 invector.push_back(token);
623 pos_ant = pos+1;
624 pos = includeliststr.find(_T("\n"), pos_ant);
626 if (!includeliststr.empty())
628 invector.push_back(includeliststr.substr(pos_ant, includeliststr.size()-1));
630 includeliststr = (stdstring)includelist;
634 struct AdminDir_s
636 BOOL bHasAdminDir;
637 stdstring sProjectRoot;
639 public:
640 CRegStdDWORD cachetype;
641 CRegStdDWORD blockstatus;
642 CRegStdDWORD langid;
643 CRegStdDWORD showrecursive;
644 CRegStdDWORD folderoverlay;
645 CRegStdDWORD getlocktop;
646 CRegStdDWORD driveremote;
647 CRegStdDWORD drivefixed;
648 CRegStdDWORD drivecdrom;
649 CRegStdDWORD driveremove;
650 CRegStdDWORD drivefloppy;
651 CRegStdDWORD driveram;
652 CRegStdDWORD driveunknown;
653 CRegStdDWORD menulayoutlow; /* Fist level mask */
654 CRegStdDWORD menulayouthigh;
655 CRegStdDWORD shellmenuaccelerators;
656 CRegStdDWORD menuextlow; /* ext menu mask */
657 CRegStdDWORD menuexthigh;
658 CRegStdDWORD simplecontext;
659 CRegStdDWORD menumasklow_lm;
660 CRegStdDWORD menumaskhigh_lm;
661 CRegStdDWORD menumasklow_cu;
662 CRegStdDWORD menumaskhigh_cu;
663 CRegStdDWORD unversionedasmodified;
664 CRegStdDWORD showunversionedoverlay;
665 CRegStdDWORD showignoredoverlay;
666 CRegStdDWORD excludedasnormal;
667 CRegStdString excludelist;
668 CRegStdDWORD hidemenusforunversioneditems;
669 CRegStdDWORD columnseverywhere;
670 stdstring excludeliststr;
671 std::vector<stdstring> exvector;
672 CRegStdString includelist;
673 stdstring includeliststr;
674 std::vector<stdstring> invector;
675 DWORD cachetypeticker;
676 DWORD recursiveticker;
677 DWORD folderoverlayticker;
678 DWORD getlocktopticker;
679 DWORD driveticker;
680 DWORD drivetypeticker;
681 DWORD layoutticker;
682 DWORD exticker;
683 DWORD menumaskticker;
684 DWORD langticker;
685 DWORD blockstatusticker;
686 DWORD columnrevformatticker;
687 DWORD excludelistticker;
688 DWORD includelistticker;
689 DWORD simplecontextticker;
690 DWORD shellmenuacceleratorsticker;
691 DWORD unversionedasmodifiedticker;
692 DWORD showunversionedoverlayticker;
693 DWORD showignoredoverlayticker;
694 DWORD excludedasnormalticker;
695 DWORD hidemenusforunversioneditemsticker;
696 DWORD columnseverywhereticker;
697 UINT drivetypecache[27];
698 TCHAR drivetypepathcache[MAX_PATH]; // MAX_PATH ok.
699 NUMBERFMT columnrevformat;
700 TCHAR szDecSep[5];
701 TCHAR szThousandsSep[5];
702 std::map<stdstring, AdminDir_s> admindircache;
703 stdstring sAdminDirCacheKey;
704 CRegStdString nocontextpaths;
705 stdstring excludecontextstr;
706 std::vector<stdstring> excontextvector;
707 DWORD excontextticker;
708 DWORD admindirticker;
709 CComCriticalSection m_critSec;