Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in tip

fogcreek shellext: eliminate redundant code

Changeset 59aa1a92d3fe

Parent 5fb8cb474d54

by David Golub

Changes to 8 files · Browse files at 59aa1a92d3fe Showing diff from parent 5fb8cb474d54 Diff from another changeset...

 
19
20
21
22
23
24
 
25
26
27
 
45
46
47
48
 
49
50
51
 
54
55
56
57
 
58
59
60
 
81
82
83
84
 
85
86
87
 
19
20
21
 
22
 
23
24
25
26
 
44
45
46
 
47
48
49
50
 
53
54
55
 
56
57
58
59
 
80
81
82
 
83
84
85
86
@@ -19,9 +19,8 @@
   #include "Dirstatecache.h"  #include "dirstate.h" -#include "Winstat64.h"  #include "Thgstatus.h" - +#include "Winstat.h"    std::list<Dirstatecache::E>& Dirstatecache::cache()  { @@ -45,7 +44,7 @@
  break;   }   - Winstat64 stat; + Winstat stat;   std::string path = hgroot + (usekbfiles ? "\\.hg\\kilnbfiles\\dirstate"   : "\\.hg\\dirstate");   @@ -54,7 +53,7 @@
    if (iter == cache().end())   { - if (stat.lstat(path.c_str()) != 0) + if (stat.lstat(path.c_str(), true) != 0)   {   TDEBUG_TRACE("Dirstatecache::get: lstat(" << path <<") failed");   return 0; @@ -81,7 +80,7 @@
    if (!new_stat && tc - iter->tickcount > 500)   { - if (0 != stat.lstat(path.c_str())) + if (0 != stat.lstat(path.c_str(), true))   {   TDEBUG_TRACE("Dirstatecache::get: lstat(" << path <<") failed");   TDEBUG_TRACE("Dirstatecache::get: dropping " << iter->hgroot);
 
22
23
24
25
26
27
28
 
96
97
98
99
100
 
 
101
102
103
 
22
23
24
 
25
26
27
 
95
96
97
 
 
98
99
100
101
102
@@ -22,7 +22,6 @@
 #include "DirectoryStatus.h"  #include "Dirstatecache.h"  #include "Winstat.h" -#include "Winstat64.h"  #include "TortoiseUtils.h"  #include "Thgstatus.h"   @@ -96,8 +95,8 @@
  {   p.resize(pos);   p += "\\.hg\\kilnbfiles\\dirstate"; - Winstat64 stat; - if (stat.lstat(p.c_str()) == 0) + Winstat stat; + if (stat.lstat(p.c_str(), true) == 0)   {   // ignore files and dirs named '.kbf' when kbfiles is enabled   last = cur;
 
214
215
216
217
218
219
220
 
242
243
244
245
246
247
248
 
214
215
216
 
217
218
219
 
241
242
243
 
244
245
246
@@ -214,7 +214,6 @@
  <ClCompile Include="TortoiseIconBitmap.cpp" />   <ClCompile Include="TortoiseUtils.cpp" />   <ClCompile Include="Winstat.cpp" /> - <ClCompile Include="Winstat64.cpp" />   </ItemGroup>   <ItemGroup>   <ClInclude Include="CShellExtCMenu.h" /> @@ -242,7 +241,6 @@
  <ClInclude Include="TortoiseIconBitmap.h" />   <ClInclude Include="TortoiseUtils.h" />   <ClInclude Include="Winstat.h" /> - <ClInclude Include="Winstat64.h" />   </ItemGroup>   <ItemGroup>   <None Include="ShellExt.def" />
 
81
82
83
84
85
86
87
88
89
 
161
162
163
164
165
166
167
168
169
 
81
82
83
 
 
 
84
85
86
 
158
159
160
 
 
 
161
162
163
@@ -81,9 +81,6 @@
  <ClCompile Include="Winstat.cpp">   <Filter>Source Files</Filter>   </ClCompile> - <ClCompile Include="Winstat64.cpp"> - <Filter>Source Files</Filter> - </ClCompile>   </ItemGroup>   <ItemGroup>   <ClInclude Include="CShellExtCMenu.h"> @@ -161,9 +158,6 @@
  <ClInclude Include="Winstat.h">   <Filter>Header Files</Filter>   </ClInclude> - <ClInclude Include="Winstat64.h"> - <Filter>Header Files</Filter> - </ClInclude>   </ItemGroup>   <ItemGroup>   <None Include="ShellExt.def">
 
1
 
2
3
4
 
19
20
21
22
 
23
24
25
 
34
35
36
37
 
 
 
 
 
 
38
39
40
 
 
1
2
3
4
 
19
20
21
 
22
23
24
25
 
34
35
36
 
37
38
39
40
41
42
43
44
45
@@ -1,4 +1,4 @@
- +// Copyright (C) 2011 Fog Creek Software  // Copyright (C) 2009 Benjamin Pollack  //  // This program is free software: you can redistribute it and/or modify @@ -19,7 +19,7 @@
 #include "Winstat.h"     -int Winstat::lstat(const char* file) +int Winstat::lstat(const char* file, bool time64)  {   const __int64 days_between_epochs = 134774L; /* days between 1.1.1601 and 1.1.1970 */   const __int64 secs_between_epochs = (__int64)days_between_epochs * 86400L; @@ -34,7 +34,12 @@
  FindClose(hfind);     this->mtime = (((__int64)data.ftLastWriteTime.dwHighDateTime << 32) + - data.ftLastWriteTime.dwLowDateTime) / divisor - secs_between_epochs; + data.ftLastWriteTime.dwLowDateTime); + if (!time64) + { + mtime /= divisor; + mtime -= secs_between_epochs; + }   this->size = ((__int64)data.nFileSizeHigh << 32) + data.nFileSizeLow;   this->isdir = (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;  
 
1
 
2
3
4
 
24
25
26
27
 
28
29
30
 
 
1
2
3
4
 
24
25
26
 
27
28
29
30
@@ -1,4 +1,4 @@
- +// Copyright (C) 2011 Fog Creek Software  // Copyright (C) 2009 Benjamin Pollack  //  // This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@
  unsigned __int64 mtime;   bool isdir;   - int lstat(const char* file); + int lstat(const char* file, bool time64 = false);  };    #endif
Change 1 of 1 Show Entire File win32/​shellext/​Winstat64.cpp Stacked
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
@@ -1,36 +0,0 @@
- -// Copyright (C) 2009 Adrian Buehlmann -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see <http://www.gnu.org/licenses/>. - -#include "stdafx.h" - -#include "Winstat64.h" - -int Winstat64::lstat(const char* path) -{ - WIN32_FIND_DATAA data; - HANDLE hfind; - - hfind = FindFirstFileA(path, &data); - if (hfind == INVALID_HANDLE_VALUE) - return -1; - FindClose(hfind); - - this->mtime = ((__int64)data.ftLastWriteTime.dwHighDateTime << 32) - + data.ftLastWriteTime.dwLowDateTime; - this->size = ((__int64)data.nFileSizeHigh << 32) + data.nFileSizeLow; - - return 0; -}
Change 1 of 1 Show Entire File win32/​shellext/​Winstat64.h Stacked
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
@@ -1,27 +0,0 @@
- -// Copyright (C) 2009 Adrian Buehlmann -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see <http://www.gnu.org/licenses/>. - -#ifndef WINSTAT64_H -#define WINSTAT64_H - -struct Winstat64 -{ - __int64 mtime; - __int64 size; - int lstat(const char* path); -}; - -#endif