[Box Backup-commit] COMMIT r1516 - box/chris/general/bin/bbackupquery

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Mon Apr 16 08:08:51 BST 2007


Author: chris
Date: 2007-04-16 08:08:51 +0100 (Mon, 16 Apr 2007)
New Revision: 1516

Modified:
   box/chris/general/bin/bbackupquery/BackupQueries.cpp
Log:
Return an error code on failure of lcd command.

Return an error code if get command fails due to the file already existing.


Modified: box/chris/general/bin/bbackupquery/BackupQueries.cpp
===================================================================
--- box/chris/general/bin/bbackupquery/BackupQueries.cpp	2007-04-15 21:54:17 UTC (rev 1515)
+++ box/chris/general/bin/bbackupquery/BackupQueries.cpp	2007-04-16 07:08:51 UTC (rev 1516)
@@ -54,11 +54,11 @@
 #undef min
 #undef max
 
-#define COMPARE_RETURN_SAME			1
+#define COMPARE_RETURN_SAME		1
 #define COMPARE_RETURN_DIFFERENT	2
 #define COMPARE_RETURN_ERROR		3
+#define COMMAND_RETURN_ERROR		4
 
-
 // --------------------------------------------------------------------------
 //
 // Function
@@ -785,13 +785,19 @@
 	if(args.size() != 1 || args[0].size() == 0)
 	{
 		printf("Incorrect usage.\nlcd <local-directory>\n");
+		SetReturnCode(COMMAND_RETURN_ERROR);
 		return;
 	}
 	
 	// Try changing directory
 #ifdef WIN32
 	std::string dirName;
-	if(!ConvertConsoleToUtf8(args[0].c_str(), dirName)) return;
+	if(!ConvertConsoleToUtf8(args[0].c_str(), dirName))
+	{
+		printf("Failed to convert path from console encoding.\n");
+		SetReturnCode(COMMAND_RETURN_ERROR);
+		return;
+	}
 	int result = ::chdir(dirName.c_str());
 #else
 	int result = ::chdir(args[0].c_str());
@@ -800,6 +806,7 @@
 	{
 		printf((errno == ENOENT || errno == ENOTDIR)?"Directory '%s' does not exist\n":"Error changing dir to '%s'\n",
 			args[0].c_str());
+		SetReturnCode(COMMAND_RETURN_ERROR);
 		return;
 	}
 	
@@ -808,11 +815,17 @@
 	if(::getcwd(wd, PATH_MAX) == 0)
 	{
 		printf("Error getting current directory\n");
+		SetReturnCode(COMMAND_RETURN_ERROR);
 		return;
 	}
 
 #ifdef WIN32
-	if(!ConvertUtf8ToConsole(wd, dirName)) return;
+	if(!ConvertUtf8ToConsole(wd, dirName))
+	{
+		printf("Failed to convert new path from console encoding.\n");
+		SetReturnCode(COMMAND_RETURN_ERROR);
+		return;
+	}
 	printf("Local current directory is now '%s'\n", dirName.c_str());
 #else
 	printf("Local current directory is now '%s'\n", wd);
@@ -1013,7 +1026,9 @@
 	struct stat st;
 	if(::stat(localName.c_str(), &st) == 0 || errno != ENOENT)
 	{
-		printf("The local file %s already exists, will not overwrite it.\n", localName.c_str());
+		printf("The local file %s already exists, will not "
+			"overwrite it.\n", localName.c_str());
+		SetReturnCode(COMMAND_RETURN_ERROR);
 		return;
 	}
 	




More information about the Boxbackup-commit mailing list