[Box Backup-commit] COMMIT r1012 - box/chris/general/bin/bbstored

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Fri Oct 13 23:51:59 BST 2006


Author: chris
Date: 2006-10-13 23:51:59 +0100 (Fri, 13 Oct 2006)
New Revision: 1012

Modified:
   box/chris/general/bin/bbstored/BackupCommands.cpp
Log:
 * Use InvisibleTempFileStream instead of FileStream for temporary files


Modified: box/chris/general/bin/bbstored/BackupCommands.cpp
===================================================================
--- box/chris/general/bin/bbstored/BackupCommands.cpp	2006-10-13 22:38:57 UTC (rev 1011)
+++ box/chris/general/bin/bbstored/BackupCommands.cpp	2006-10-13 22:51:59 UTC (rev 1012)
@@ -29,6 +29,7 @@
 #include "BackupStoreInfo.h"
 #include "RaidFileController.h"
 #include "FileStream.h"
+#include "InvisibleTempFileStream.h"
 
 #include "MemLeakFindOn.h"
 
@@ -332,15 +333,11 @@
 			std::auto_ptr<IOStream> diff2(rContext.OpenObject(patchID));
 			
 			// Choose a temporary filename for the result of the combination
-#ifdef WIN32
 			std::ostringstream fs(rContext.GetStoreRoot());
 			fs << ".recombinetemp.";
 			fs << p;
 			std::string tempFn(fs.str());
 			tempFn = RaidFileController::DiscSetPathToFileSystemPath(rContext.GetStoreDiscSet(), tempFn, p + 16);
-#else
-			std::string tempFn(RaidFileController::DiscSetPathToFileSystemPath(rContext.GetStoreDiscSet(), rContext.GetStoreRoot() + ".recombinetemp", p + 16 /* rotate which disc it's on */));
-#endif
 			
 			// Open the temporary file
 			std::auto_ptr<IOStream> combined;
@@ -348,23 +345,14 @@
 			{
 				{
 					// Write nastily to allow this to work with gcc 2.x
-#ifdef WIN32
-					combined.reset(new FileStream(
-						tempFn.c_str(), 
-						O_RDWR | O_CREAT | O_EXCL | 
-						O_BINARY | O_TRUNC));
-#else
-					std::auto_ptr<IOStream> t(new FileStream(tempFn.c_str(), O_RDWR | O_CREAT | O_EXCL));
+					std::auto_ptr<IOStream> t(
+						new InvisibleTempFileStream(
+							tempFn.c_str(), 
+							O_RDWR | O_CREAT | 
+							O_EXCL | O_BINARY | 
+							O_TRUNC));
 					combined = t;
-#endif
 				}
-#ifndef WIN32
-				// Unlink immediately as it's a temporary file
-				if(::unlink(tempFn.c_str()) != 0)
-				{
-					THROW_EXCEPTION(CommonException, OSFileError);
-				}
-#endif
 			}
 			catch(...)
 			{
@@ -380,9 +368,7 @@
 			combined->Seek(0, IOStream::SeekType_Absolute);
 			
 			// Then shuffle round for the next go
-#ifdef WIN32
 			if (from.get()) from->Close();
-#endif
 			from = combined;
 		}
 		




More information about the Boxbackup-commit mailing list