[Box Backup-commit] COMMIT r2182 - box/trunk/bin/bbackupquery

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Wed May 28 16:25:59 BST 2008


Author: chris
Date: 2008-05-28 16:25:59 +0100 (Wed, 28 May 2008)
New Revision: 2182

Modified:
   box/trunk/bin/bbackupquery/BackupQueries.cpp
   box/trunk/bin/bbackupquery/BackupQueries.h
Log:
Use symbolic names instead of #defines for return codes.


Modified: box/trunk/bin/bbackupquery/BackupQueries.cpp
===================================================================
--- box/trunk/bin/bbackupquery/BackupQueries.cpp	2008-05-28 15:24:05 UTC (rev 2181)
+++ box/trunk/bin/bbackupquery/BackupQueries.cpp	2008-05-28 15:25:59 UTC (rev 2182)
@@ -122,7 +122,7 @@
 		{
 			BOX_WARNING("System command returned error code " <<
 				result);
-			SetReturnCode(COMMAND_RETURN_ERROR);
+			SetReturnCode(ReturnCode::Command_Error);
 		}
 		return;
 	}
@@ -295,7 +295,7 @@
 	if(cmd != COMMAND_Quit && cmd != COMMAND_Exit)
 	{
 		// If not a quit command, set the return code to zero
-		SetReturnCode(0);
+		SetReturnCode(ReturnCode::Command_OK);
 	}
 
 	// Handle command
@@ -410,7 +410,7 @@
 		{
 			BOX_ERROR("Directory '" << args[0] << "' not found "
 				"on store.");
-			SetReturnCode(COMMAND_RETURN_ERROR);
+			SetReturnCode(ReturnCode::Command_Error);
 			return;
 		}
 	}
@@ -448,13 +448,13 @@
 	catch (std::exception &e)
 	{
 		BOX_ERROR("Failed to list directory: " << e.what());
-		SetReturnCode(COMMAND_RETURN_ERROR);
+		SetReturnCode(ReturnCode::Command_Error);
 		return;
 	}
 	catch (...)
 	{
 		BOX_ERROR("Failed to list directory: unknown error");
-		SetReturnCode(COMMAND_RETURN_ERROR);
+		SetReturnCode(ReturnCode::Command_Error);
 		return;
 	}
 
@@ -773,7 +773,7 @@
 	if(args.size() != 1 || args[0].size() == 0)
 	{
 		BOX_ERROR("Incorrect usage. cd [-o] [-d] <directory>");
-		SetReturnCode(COMMAND_RETURN_ERROR);
+		SetReturnCode(ReturnCode::Command_Error);
 		return;
 	}
 
@@ -791,7 +791,7 @@
 	if(id == 0)
 	{
 		BOX_ERROR("Directory '" << args[0] << "' not found.");
-		SetReturnCode(COMMAND_RETURN_ERROR);
+		SetReturnCode(ReturnCode::Command_Error);
 		return;
 	}
 	
@@ -813,7 +813,7 @@
 	if(args.size() != 1 || args[0].size() == 0)
 	{
 		BOX_ERROR("Incorrect usage. lcd <local-directory>");
-		SetReturnCode(COMMAND_RETURN_ERROR);
+		SetReturnCode(ReturnCode::Command_Error);
 		return;
 	}
 	
@@ -823,7 +823,7 @@
 	if(!ConvertConsoleToUtf8(args[0].c_str(), dirName))
 	{
 		BOX_ERROR("Failed to convert path from console encoding.");
-		SetReturnCode(COMMAND_RETURN_ERROR);
+		SetReturnCode(ReturnCode::Command_Error);
 		return;
 	}
 	int result = ::chdir(dirName.c_str());
@@ -842,7 +842,7 @@
 				"'" << args[0] << "'");
 		}
 
-		SetReturnCode(COMMAND_RETURN_ERROR);
+		SetReturnCode(ReturnCode::Command_Error);
 		return;
 	}
 	
@@ -851,7 +851,7 @@
 	if(::getcwd(wd, PATH_MAX) == 0)
 	{
 		BOX_LOG_SYS_ERROR("Error getting current directory");
-		SetReturnCode(COMMAND_RETURN_ERROR);
+		SetReturnCode(ReturnCode::Command_Error);
 		return;
 	}
 
@@ -859,7 +859,7 @@
 	if(!ConvertUtf8ToConsole(wd, dirName))
 	{
 		BOX_ERROR("Failed to convert new path from console encoding.");
-		SetReturnCode(COMMAND_RETURN_ERROR);
+		SetReturnCode(ReturnCode::Command_Error);
 		return;
 	}
 	BOX_INFO("Local current directory is now '" << dirName << "'.");
@@ -1069,7 +1069,7 @@
 	{
 		BOX_ERROR("The local file " << localName << " already exists, "
 			"will not overwrite it.");
-		SetReturnCode(COMMAND_RETURN_ERROR);
+		SetReturnCode(ReturnCode::Command_Error);
 		return;
 	}
 	
@@ -1268,15 +1268,15 @@
 	{
 		if (params.mUncheckedFiles != 0)
 		{
-			SetReturnCode(COMPARE_RETURN_ERROR);
+			SetReturnCode(ReturnCode::Compare_Error);
 		} 
 		else if (params.mDifferences != 0)
 		{
-			SetReturnCode(COMPARE_RETURN_DIFFERENT);
+			SetReturnCode(ReturnCode::Compare_Different);
 		}
 		else
 		{
-			SetReturnCode(COMPARE_RETURN_SAME);
+			SetReturnCode(ReturnCode::Compare_Same);
 		}
 	}
 }
@@ -2055,13 +2055,13 @@
 	catch(std::exception &e)
 	{
 		BOX_ERROR("Failed to restore: " << e.what());
-		SetReturnCode(COMMAND_RETURN_ERROR);
+		SetReturnCode(ReturnCode::Command_Error);
 		return;
 	}
 	catch(...)
 	{
 		BOX_ERROR("Failed to restore: unknown exception");
-		SetReturnCode(COMMAND_RETURN_ERROR);
+		SetReturnCode(ReturnCode::Command_Error);
 		return;
 	}
 
@@ -2079,30 +2079,30 @@
 	case Restore_ResumePossible:
 		BOX_ERROR("Resume possible -- repeat command with -r flag "
 			"to resume.");
-		SetReturnCode(COMMAND_RETURN_ERROR);
+		SetReturnCode(ReturnCode::Command_Error);
 		break;
 	
 	case Restore_TargetExists:
 		BOX_ERROR("The target directory exists. You cannot restore "
 			"over an existing directory.");
-		SetReturnCode(COMMAND_RETURN_ERROR);
+		SetReturnCode(ReturnCode::Command_Error);
 		break;
 		
 	case Restore_TargetPathNotFound:
 		BOX_ERROR("The target directory path does not exist.\n"
 			"To restore to a directory whose parent "
 			"does not exist, create the parent first.");
-		SetReturnCode(COMMAND_RETURN_ERROR);
+		SetReturnCode(ReturnCode::Command_Error);
 		break;
 
 	case Restore_UnknownError:
 		BOX_ERROR("Unknown error during restore.");
-		SetReturnCode(COMMAND_RETURN_ERROR);
+		SetReturnCode(ReturnCode::Command_Error);
 		break;
 
 	default:
 		BOX_ERROR("Unknown restore result " << result << ".");
-		SetReturnCode(COMMAND_RETURN_ERROR);
+		SetReturnCode(ReturnCode::Command_Error);
 		break;
 	}
 }

Modified: box/trunk/bin/bbackupquery/BackupQueries.h
===================================================================
--- box/trunk/bin/bbackupquery/BackupQueries.h	2008-05-28 15:24:05 UTC (rev 2181)
+++ box/trunk/bin/bbackupquery/BackupQueries.h	2008-05-28 15:25:59 UTC (rev 2182)
@@ -79,10 +79,29 @@
 		const ExcludeList *mpExcludeDirs;
 		box_time_t mLatestFileUploadTime;
 	};
-	void CompareLocation(const std::string &rLocation, CompareParams &rParams);
-	void Compare(const std::string &rStoreDir, const std::string &rLocalDir, CompareParams &rParams);
-	void Compare(int64_t DirID, const std::string &rStoreDir, const std::string &rLocalDir, CompareParams &rParams);
+	void CompareLocation(const std::string &rLocation,
+		CompareParams &rParams);
+	void Compare(const std::string &rStoreDir,
+		const std::string &rLocalDir, CompareParams &rParams);
+	void Compare(int64_t DirID, const std::string &rStoreDir,
+		const std::string &rLocalDir, CompareParams &rParams);
 
+public:
+
+	class ReturnCode
+	{
+		public:
+		enum {
+			Command_OK = 0,
+			Compare_Same = 1,
+			Compare_Different,
+			Compare_Error,
+			Command_Error,
+		} Type;
+	};
+
+private:
+
 	// Utility functions
 	int64_t FindDirectoryObjectID(const std::string &rDirName, bool AllowOldVersion = false,
 		bool AllowDeletedDirs = false, std::vector<std::pair<std::string, int64_t> > *pStack = 0);




More information about the Boxbackup-commit mailing list