[Box Backup-commit] COMMIT r3563 - box/trunk/lib/raidfile

subversion at boxbackup.org subversion at boxbackup.org
Sat May 16 10:17:11 BST 2015


Author: chris
Date: 2015-05-16 09:17:11 +0000 (Sat, 16 May 2015)
New Revision: 3563

Modified:
   box/trunk/lib/raidfile/RaidFileUtil.cpp
Log:
Use FileModificationTime instead of raw stat() on Windows.

Fixes test failures caused by using seconds since epoch on Windows, instead
of a box_time_t, and rounding it to the nearest 10^6, which is fine for a
box_time_t (all other platforms), but 10^6 seconds is a rather long time to
ignore changes for on Windows.

This also makes it possible to support subsecond precision on Windows
via FileModificationTime() in future, and have RaidFile detect such subsecond
changes.

Modified: box/trunk/lib/raidfile/RaidFileUtil.cpp
===================================================================
--- box/trunk/lib/raidfile/RaidFileUtil.cpp	2015-05-16 09:17:07 UTC (rev 3562)
+++ box/trunk/lib/raidfile/RaidFileUtil.cpp	2015-05-16 09:17:11 UTC (rev 3563)
@@ -59,8 +59,7 @@
 		*pExistingFiles = 0;
 	}
 	
-	// For stat call, although the results are not examined
-	struct stat st;
+	EMU_STRUCT_STAT st;
 
 	// check various files
 	int startDisc = 0;
@@ -70,7 +69,7 @@
 		{
 			*pStartDisc = startDisc;
 		}
-		if(::stat(writeFile.c_str(), &st) == 0)
+		if(EMU_STAT(writeFile.c_str(), &st) == 0)
 		{
 			// write file exists, use that
 			
@@ -77,12 +76,7 @@
 			// Get unique ID
 			if(pRevisionID != 0)
 			{
-				#ifdef WIN32
-					*pRevisionID = st.st_mtime;
-				#else
-					*pRevisionID = FileModificationTime(st);
-				#endif
-
+				*pRevisionID = FileModificationTime(st);
 				*pRevisionID = adjust_timestamp(*pRevisionID, st.st_size);
 			}
 			
@@ -102,7 +96,7 @@
 	for(int f = 0; f < setSize; ++f)
 	{
 		std::string componentFile(RaidFileUtil::MakeRaidComponentName(rDiscSet, rFilename, (f + startDisc) % setSize));
-		if(::stat(componentFile.c_str(), &st) == 0)
+		if(EMU_STAT(componentFile.c_str(), &st) == 0)
 		{
 			// Component file exists, add to count
 			rfCount++;
@@ -114,12 +108,7 @@
 			// Revision ID
 			if(pRevisionID != 0)
 			{
-				#ifdef WIN32
-					int64_t rid = st.st_mtime;
-				#else
-					int64_t rid = FileModificationTime(st);
-				#endif
-
+				int64_t rid = FileModificationTime(st);
 				if(rid > revisionID) revisionID = rid;
 				revisionIDplus += st.st_size;
 			}




More information about the Boxbackup-commit mailing list