[Box Backup-dev] COMMIT r640 - box/chris/general/bin/bbackupquery
boxbackup-dev at fluffy.co.uk
boxbackup-dev at fluffy.co.uk
Thu Jul 6 21:59:54 BST 2006
Author: chris
Date: 2006-07-06 20:59:52 +0000 (Thu, 06 Jul 2006)
New Revision: 640
Modified:
box/chris/general/bin/bbackupquery/BackupQueries.cpp
box/chris/general/bin/bbackupquery/BackupQueries.h
box/chris/general/bin/bbackupquery/documentation.txt
Log:
* BackupQueries.cpp, BackupQueries.h, documentation.txt
- Changed to use a structure to hold command names and options, to make
the code more maintainable
- Added a 'compare -A' option to compare normally but without attributes.
On Windows, restoring the attributes is impossible (except in Vista)
due to lack of utimes() equivalent function, as far as I can tell.
Modified: box/chris/general/bin/bbackupquery/BackupQueries.cpp
===================================================================
--- box/chris/general/bin/bbackupquery/BackupQueries.cpp 2006-07-06 20:57:11 UTC (rev 639)
+++ box/chris/general/bin/bbackupquery/BackupQueries.cpp 2006-07-06 20:59:52 UTC (rev 640)
@@ -84,6 +84,12 @@
{
}
+typedef struct cmd_info
+{
+ const char* name;
+ const char* opts;
+} cmd_info_t;
+
// --------------------------------------------------------------------------
//
// Function
@@ -161,8 +167,24 @@
}
// Data about commands
- static const char *commandNames[] = {"quit", "exit", "list", "pwd", "cd", "lcd", "sh", "getobject", "get", "compare", "restore", "help", "usage", "undelete", 0};
- static const char *validOptions[] = {"", "", "rodIFtTsh", "", "od", "", "", "", "i", "alcqE", "dri", "", "", "", 0};
+ static cmd_info_t commands[] =
+ {
+ { "quit", "" },
+ { "exit", "" },
+ { "list", "rodIFtTsh", },
+ { "pwd", "" },
+ { "cd", "od" },
+ { "lcd", "" },
+ { "sh", "" },
+ { "getobject", "" },
+ { "get", "i" },
+ { "compare", "alcqAE" },
+ { "restore", "dri" },
+ { "help", "" },
+ { "usage", "" },
+ { "undelete", "" },
+ { NULL, NULL }
+ };
#define COMMAND_Quit 0
#define COMMAND_Exit 1
#define COMMAND_List 2
@@ -182,11 +204,11 @@
// Work out which command it is...
int cmd = 0;
- while(commandNames[cmd] != 0 && ::strcmp(cmdElements[0].c_str(), commandNames[cmd]) != 0)
+ while(commands[cmd].name != 0 && ::strcmp(cmdElements[0].c_str(), commands[cmd].name) != 0)
{
cmd++;
}
- if(commandNames[cmd] == 0)
+ if(commands[cmd].name == 0)
{
// Check for aliases
int a;
@@ -221,9 +243,10 @@
while(*c != 0)
{
// Valid option?
- if(::strchr(validOptions[cmd], *c) == NULL)
+ if(::strchr(commands[cmd].opts, *c) == NULL)
{
- printf("Invalid option '%c' for command %s\n", *c, commandNames[cmd]);
+ printf("Invalid option '%c' for command %s\n",
+ *c, commands[cmd].name);
return;
}
opts[(int)*c] = true;
@@ -990,6 +1013,7 @@
BackupQueries::CompareParams::CompareParams()
: mQuickCompare(false),
mIgnoreExcludes(false),
+ mIgnoreAttributes(false),
mDifferences(0),
mDifferencesExplainedByModTime(0),
mExcludedDirs(0),
@@ -1052,6 +1076,7 @@
BackupQueries::CompareParams params;
params.mQuickCompare = opts['q'];
params.mIgnoreExcludes = opts['E'];
+ params.mIgnoreAttributes = opts['A'];
// Try and work out the time before which all files should be on the server
{
@@ -1484,11 +1509,12 @@
}
// Compare attributes
+ box_time_t fileModTime = 0;
BackupClientFileAttributes localAttr;
- box_time_t fileModTime = 0;
localAttr.ReadAttributes(localPath.c_str(), false /* don't zero mod times */, &fileModTime);
modifiedAfterLastSync = (fileModTime > rParams.mLatestFileUploadTime);
- if(!localAttr.Compare(fileOnServerStream->GetAttributes(),
+ if(!rParams.mIgnoreAttributes &&
+ !localAttr.Compare(fileOnServerStream->GetAttributes(),
true /* ignore attr mod time */,
fileOnServerStream->IsSymLink() /* ignore modification time if it's a symlink */))
{
Modified: box/chris/general/bin/bbackupquery/BackupQueries.h
===================================================================
--- box/chris/general/bin/bbackupquery/BackupQueries.h 2006-07-06 20:57:11 UTC (rev 639)
+++ box/chris/general/bin/bbackupquery/BackupQueries.h 2006-07-06 20:59:52 UTC (rev 640)
@@ -68,6 +68,7 @@
void DeleteExcludeLists();
bool mQuickCompare;
bool mIgnoreExcludes;
+ bool mIgnoreAttributes;
int mDifferences;
int mDifferencesExplainedByModTime;
int mExcludedDirs;
Modified: box/chris/general/bin/bbackupquery/documentation.txt
===================================================================
--- box/chris/general/bin/bbackupquery/documentation.txt 2006-07-06 20:57:11 UTC (rev 639)
+++ box/chris/general/bin/bbackupquery/documentation.txt 2006-07-06 20:59:52 UTC (rev 640)
@@ -104,6 +104,7 @@
-c -- set return code
-q -- quick compare. Only checks file contents against checksums,
doesn't do a full download
+ -A -- ignore attribute differences
-E -- ignore exclusion settings
Comparing with the root directory is an error, use -a option instead.
More information about the Boxbackup-dev
mailing list