[Box Backup-commit] COMMIT r2536 - box/trunk/lib/common

boxbackup-dev at boxbackup.org boxbackup-dev at boxbackup.org
Sun Jun 28 20:05:08 BST 2009


Author: chris
Date: 2009-06-28 20:05:07 +0100 (Sun, 28 Jun 2009)
New Revision: 2536

Modified:
   box/trunk/lib/common/NamedLock.cpp
   box/trunk/lib/common/NamedLock.h
Log:
Make NamedLock take a std::string instead of a char pointer for C++ 
style.


Modified: box/trunk/lib/common/NamedLock.cpp
===================================================================
--- box/trunk/lib/common/NamedLock.cpp	2009-06-28 12:04:25 UTC (rev 2535)
+++ box/trunk/lib/common/NamedLock.cpp	2009-06-28 19:05:07 UTC (rev 2536)
@@ -65,7 +65,7 @@
 //		Created: 2003/08/28
 //
 // --------------------------------------------------------------------------
-bool NamedLock::TryAndGetLock(const char *Filename, int mode)
+bool NamedLock::TryAndGetLock(const std::string& rFilename, int mode)
 {
 	// Check
 	if(mFileDescriptor != -1)
@@ -75,7 +75,8 @@
 
 	// See if the lock can be got
 #if HAVE_DECL_O_EXLOCK
-	int fd = ::open(Filename, O_WRONLY | O_NONBLOCK | O_CREAT | O_TRUNC | O_EXLOCK, mode);
+	int fd = ::open(rFilename.c_str(),
+		O_WRONLY | O_NONBLOCK | O_CREAT | O_TRUNC | O_EXLOCK, mode);
 	if(fd != -1)
 	{
 		// Got a lock, lovely
@@ -92,10 +93,10 @@
 
 	return false;
 #else
-	int fd = ::open(Filename, O_WRONLY | O_CREAT | O_TRUNC, mode);
+	int fd = ::open(rFilename.c_str(), O_WRONLY | O_CREAT | O_TRUNC, mode);
 	if(fd == -1)
 	{
-		BOX_WARNING("Failed to open lockfile: " << Filename);
+		BOX_WARNING("Failed to open lockfile: " << rFilename);
 		THROW_EXCEPTION(CommonException, OSFileError)
 	}
 

Modified: box/trunk/lib/common/NamedLock.h
===================================================================
--- box/trunk/lib/common/NamedLock.h	2009-06-28 12:04:25 UTC (rev 2535)
+++ box/trunk/lib/common/NamedLock.h	2009-06-28 19:05:07 UTC (rev 2536)
@@ -28,7 +28,7 @@
 	NamedLock(const NamedLock &);
 
 public:
-	bool TryAndGetLock(const char *Filename, int mode = 0755);
+	bool TryAndGetLock(const std::string& rFilename, int mode = 0755);
 	bool GotLock() {return mFileDescriptor != -1;}
 	void ReleaseLock();
 	




More information about the Boxbackup-commit mailing list