Revision: 3944
http://svn.sourceforge.net/winmerge/?rev=3944&view=rev
Author: kimmov
Date: 2006-12-11 14:06:57 -0800 (Mon, 11 Dec 2006)
Log Message:
-----------
PATCH: [ 1610442 ] Make time getting faster for files
Modified Paths:
--------------
branches/R2_6/Src/Changes.txt
branches/R2_6/Src/DirScan.cpp
branches/R2_6/Src/FileInfo.cpp
Modified: branches/R2_6/Src/Changes.txt
===================================================================
--- branches/R2_6/Src/Changes.txt 2006-12-11 21:08:40 UTC (rev 3943)
+++ branches/R2_6/Src/Changes.txt 2006-12-11 22:06:57 UTC (rev 3944)
@@ -2,6 +2,10 @@
Add new items to top.
(This summarizes all changes to all files under Src, including Src\Languages.)
+2006-12-11 Kimmo
+ PATCH: [ 1610442 ] Make time getting faster for files
+ Src: DirScan.cpp FileInfo.cpp
+
2006-12-10 Gal
BUG: [ 1611542 ] "Wrap lines" does not work for diff pane
Src: MergeDiffDetailView.cpp MergeDiffDetailView.h
Modified: branches/R2_6/Src/DirScan.cpp
===================================================================
--- branches/R2_6/Src/DirScan.cpp 2006-12-11 21:08:40 UTC (rev 3943)
+++ branches/R2_6/Src/DirScan.cpp 2006-12-11 22:06:57 UTC (rev 3944)
@@ -58,6 +58,8 @@
int code, DiffItemList * pList, CDiffContext *pCtxt);
static void UpdateDiffItem(DIFFITEM & di, BOOL & bExists, CDiffContext *pCtxt);
+static __int64 FiletimeToTimeT(FILETIME time);
+
/** @brief cmpmth is a typedef for a pointer to a method */
typedef int (CString::*cmpmth)(LPCTSTR sz) const;
/** @brief CALL_MEMBER_FN calls a method through a pointer to a method */
@@ -488,6 +490,22 @@
}
/**
+ * @brief Convert time in type FILETIME to type int (time_t compatible).
+ * @param [in] time Time in FILETIME type.
+ * @return Time in time_t compiliant integer.
+ */
+static __int64 FiletimeToTimeT(FILETIME time)
+{
+ const __int64 SecsTo100ns = 10000000;
+ const __int64 SecsBetweenEpochs = 11644473600;
+ __int64 converted_time;
+ converted_time = ((__int64)time.dwHighDateTime << 32) + time.dwLowDateTime;
+ converted_time -= (SecsBetweenEpochs * SecsTo100ns);
+ converted_time /= SecsTo100ns;
+ return converted_time;
+}
+
+/**
* @brief Find files and subfolders from given folder.
* This function saves all files and subfolders in given folder to arrays.
* We use 64-bit version of stat() to get times since find doesn't return
@@ -516,26 +534,25 @@
continue;
fentry ent;
- CString fullpath = paths_ConcatPath(sDir, ff.cFileName);
- struct _stati64 fstats;
- if (_tstati64(fullpath, &fstats) == 0)
+
+ // Save filetimes as seconds since January 1, 1970
+ // Note that times can be < 0 if they are around that 1970..
+ // Anyway that is not sensible case for normal files so we can
+ // just use zero for their time.
+ ent.ctime = FiletimeToTimeT(ff.ftCreationTime);
+ if (ent.ctime < 0)
+ ent.ctime = 0;
+ ent.mtime = FiletimeToTimeT(ff.ftLastWriteTime);
+ if (ent.mtime < 0)
+ ent.mtime = 0;
+
+ if (ff.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ ent.size = -1; // No size for directories
+ else
{
- // Save filetimes as seconds since January 1, 1970
- // Note that times can be < 0 if they are around that 1970..
- // Anyway that is not sensible case for normal files so we can
- // just use zero for their time.
- ent.ctime = fstats.st_ctime;
- if (ent.ctime < 0)
- ent.ctime = 0;
- ent.mtime = fstats.st_mtime;
- if (ent.mtime < 0)
- ent.mtime = 0;
+ ent.size = ((__int64)ff.nFileSizeHigh << 32) + ff.nFileSizeLow;
+ }
- if (ff.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- ent.size = -1; // No size for directories
- else
- ent.size = fstats.st_size;
- }
ent.name = ff.cFileName;
ent.attrs = ff.dwFileAttributes;
(dwIsDirectory ? dirs : files) -> Add(ent);
Modified: branches/R2_6/Src/FileInfo.cpp
===================================================================
--- branches/R2_6/Src/FileInfo.cpp 2006-12-11 21:08:40 UTC (rev 3943)
+++ branches/R2_6/Src/FileInfo.cpp 2006-12-11 22:06:57 UTC (rev 3944)
@@ -52,12 +52,12 @@
else
mtime64 = fstats.st_mtime;
- flags.attributes = GetFileAttributes(sFilePath);
-
// No size for directory ( size remains as -1)
- if ((flags.attributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
+ if ((fstats.st_mode & _S_IFDIR) == 0)
size = fstats.st_size;
+ flags.attributes = GetFileAttributes(sFilePath);
+
retVal = TRUE;
}
mtime = mtime64;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|