Changeset 7051753b84f2…
Parent 5cda5fda8327…
by
Changes to 7 files · Browse files at 7051753b84f2 Showing diff from parent 5cda5fda8327 Diff from another changeset...
@@ -18,6 +18,7 @@ #include "stdafx.h"
#include "Directory.h"
+#include "Winstat.h"
Directory::~Directory()
@@ -174,7 +175,7 @@ added = true;
}
- thg_stat stat;
+ Winstat stat;
const std::string hrs = hgroot + '\\';
for (FilesT::iterator i = files_.begin(); i != files_.end(); ++i)
{
@@ -183,7 +184,7 @@
std::string p = hrs + path(i->name);
- if (0 != lstat(p.c_str(), stat))
+ if (0 != stat.lstat(p.c_str()))
return 'M'; // file is missing, report dir as modified
char s = i->status(stat);
|
@@ -18,28 +18,7 @@ #include "stdafx.h"
#include "Direntry.h"
-
-
-int lstat(const char* file, thg_stat& rstat)
-{
- 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;
- const __int64 divisor = 10000000L;
-
- WIN32_FIND_DATAA data;
- HANDLE hfind;
-
- hfind = FindFirstFileA(file, &data);
- if (hfind == INVALID_HANDLE_VALUE)
- return -1;
- FindClose(hfind);
-
- rstat.mtime = *(__int64*)&data.ftLastWriteTime / divisor - secs_between_epochs;
- rstat.size = (data.nFileSizeHigh << sizeof(data.nFileSizeHigh)) | data.nFileSizeLow;
- rstat.isdir = (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
-
- return 0;
-}
+#include "Winstat.h"
int Direntry::read(FILE* f, std::vector<char>& relpath)
@@ -67,7 +46,7 @@}
-char Direntry::status(const thg_stat& stat) const
+char Direntry::status(const Winstat& stat) const
{
switch (this->state)
{
|
@@ -20,16 +20,7 @@
#include <vector>
-
-struct thg_stat
-{
- unsigned size;
- unsigned mtime;
- bool isdir;
-};
-
-int lstat(const char* file, thg_stat& rstat);
-
+class Winstat;
class Direntry
{
@@ -42,7 +33,7 @@ std::string name;
int read(FILE* f, std::vector<char>& relpath);
- char status(const thg_stat& stat) const;
+ char status(const Winstat& stat) const;
private:
static uint32_t ntohl(uint32_t x)
|
@@ -8,6 +8,7 @@ PipeUtils.o \
ShellUtils2.o \
StringUtils.o \
+ Winstat.o \
Direntry.o \
Directory.o \
dirstate.o
|
|
@@ -0,0 +1,41 @@ +
+// Copyright (C) 2009 Benjamin Pollack
+//
+// 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 "Winstat.h"
+
+
+int Winstat::lstat(const char* file)
+{
+ 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;
+ const __int64 divisor = 10000000L;
+
+ WIN32_FIND_DATAA data;
+ HANDLE hfind;
+
+ hfind = FindFirstFileA(file, &data);
+ if (hfind == INVALID_HANDLE_VALUE)
+ return -1;
+ FindClose(hfind);
+
+ this->mtime = *(__int64*)&data.ftLastWriteTime / divisor - secs_between_epochs;
+ this->size = (data.nFileSizeHigh << sizeof(data.nFileSizeHigh)) | data.nFileSizeLow;
+ this->isdir = (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
+
+ return 0;
+}
|
|
@@ -0,0 +1,30 @@ +
+// Copyright (C) 2009 Benjamin Pollack
+//
+// 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 WINSTAT_H
+#define WINSTAT_H
+
+class Winstat
+{
+public:
+ unsigned size;
+ unsigned mtime;
+ bool isdir;
+
+ int lstat(const char* file);
+};
+
+#endif
|
@@ -19,6 +19,7 @@ #include "dirstate.h"
#include "Directory.h"
#include "TortoiseUtils.h"
+#include "Winstat.h"
#include <shlwapi.h>
@@ -143,13 +144,13 @@
std::string path = hgroot + "\\.hg\\dirstate";
- thg_stat stat;
+ Winstat stat;
bool stat_done = false;
if (isnew || (tc - iter->tickcount) > 500)
{
- if (0 != lstat(path.c_str(), stat))
+ if (0 != stat.lstat(path.c_str()))
{
TDEBUG_TRACE("Dirstatecache::get: lstat(" << path <<") failed");
return 0;
@@ -234,8 +235,8 @@ if (!e)
return 0;
- thg_stat stat;
- if (0 != lstat(path.c_str(), stat)) {
+ Winstat stat;
+ if (0 != stat.lstat(path.c_str())) {
TDEBUG_TRACE("HgQueryDirstate: lstat(" << path << ") failed");
return 0;
}
|
Loading...