[Box Backup-commit] COMMIT r1080 - box/chris/merge/lib/backupclient

boxbackup-dev@fluffy.co.uk boxbackup-dev@fluffy.co.uk
Tue, 17 Oct 2006 00:12:24 +0100


Author: chris
Date: 2006-10-17 00:12:24 +0100 (Tue, 17 Oct 2006)
New Revision: 1080

Modified:
   box/chris/merge/lib/backupclient/BackupClientFileAttributes.cpp
Log:
Remove #ifdefs around geteuid(), re-enable use of fake version under Win32
as requested by Ben.

Restore serialised AttrModificationTime under Win32 by passing to 
emu_utimes(). (refs #3)


Modified: box/chris/merge/lib/backupclient/BackupClientFileAttributes.cpp
===================================================================
--- box/chris/merge/lib/backupclient/BackupClientFileAttributes.cpp	2006-10-16 23:10:08 UTC (rev 1079)
+++ box/chris/merge/lib/backupclient/BackupClientFileAttributes.cpp	2006-10-16 23:12:24 UTC (rev 1080)
@@ -642,11 +642,7 @@
 	}
 	
 	// If working as root, set user IDs
-	#ifdef WIN32
-	if(0)
-	#else
 	if(::geteuid() == 0)
-	#endif
 	{
 		#ifndef HAVE_LCHOWN
 			// only if not a link, can't set their owner on this platform
@@ -683,10 +679,24 @@
 	{
 		// Work out times as timevals
 		struct timeval times[2];
+
+		#ifdef WIN32
+		BoxTimeToTimeval(box_ntoh64(pattr->ModificationTime), 
+			times[1]);
+		BoxTimeToTimeval(box_ntoh64(pattr->AttrModificationTime), 
+			times[0]);
+		// Because stat() returns the creation time in the ctime
+		// field under Windows, and this gets saved in the 
+		// AttrModificationTime field of the serialised attributes,
+		// we subvert the first parameter of emu_utimes() to allow
+		// it to be reset to the right value on the restored file.
+		#else
 		BoxTimeToTimeval(modtime, times[1]);
 		// Copy access time as well, why not, got to set it to something
 		times[0] = times[1];
-		// Attr modification time will be changed anyway, nothing that can be done about it
+		// Attr modification time will be changed anyway, 
+		// nothing that can be done about it
+		#endif
 		
 		// Try to apply
 		if(::utimes(Filename, times) != 0)