From 99f8ce096bc5569adbfea1911dbcda24c28d8d8b Mon Sep 17 00:00:00 2001 From: Ben Summers Date: Fri, 14 Oct 2005 08:50:54 +0000 Subject: Box Backup 0.09 with a few tweeks --- bin/bbackupobjdump/bbackupobjdump.cpp | 82 +++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 bin/bbackupobjdump/bbackupobjdump.cpp (limited to 'bin/bbackupobjdump/bbackupobjdump.cpp') diff --git a/bin/bbackupobjdump/bbackupobjdump.cpp b/bin/bbackupobjdump/bbackupobjdump.cpp new file mode 100644 index 00000000..74fff510 --- /dev/null +++ b/bin/bbackupobjdump/bbackupobjdump.cpp @@ -0,0 +1,82 @@ +// -------------------------------------------------------------------------- +// +// File +// Name: bbackupobjdump.cpp +// Purpose: Dump contents of backup objects +// Created: 3/5/04 +// +// -------------------------------------------------------------------------- + +#include "Box.h" + +#include + +#include "MainHelper.h" +#include "FileStream.h" +#include "BackupStoreDirectory.h" +#include "BackupStoreFile.h" +#include "BackupStoreObjectMagic.h" + +#include "MemLeakFindOn.h" + +// -------------------------------------------------------------------------- +// +// Function +// Name: int main(int, const char *[]) +// Purpose: Main fn for bbackupobjdump +// Created: 3/5/04 +// +// -------------------------------------------------------------------------- +int main(int argc, const char *argv[]) +{ + MAINHELPER_START + + if(argc != 2) + { + ::printf("Input file not specified.\nUsage: bbackupobjdump \n"); + return 1; + } + + // Open file + FileStream file(argv[1]); + + // Read magic number + uint32_t signature; + if(file.Read(&signature, sizeof(signature)) != sizeof(signature)) + { + // Too short, can't read signature from it + return false; + } + // Seek back to beginning + file.Seek(0, IOStream::SeekType_Absolute); + + // Then... check depending on the type + switch(ntohl(signature)) + { + case OBJECTMAGIC_FILE_MAGIC_VALUE_V1: +#ifndef BOX_DISABLE_BACKWARDS_COMPATIBILITY_BACKUPSTOREFILE + case OBJECTMAGIC_FILE_MAGIC_VALUE_V0: +#endif + BackupStoreFile::DumpFile(stdout, false, file); + break; + + case OBJECTMAGIC_DIR_MAGIC_VALUE: + { + BackupStoreDirectory dir; + dir.ReadFromStream(file, IOStream::TimeOutInfinite); + dir.Dump(stdout, false); + if(dir.CheckAndFix()) + { + ::printf("Directory didn't pass checking\n"); + } + } + break; + + default: + ::printf("File does not appear to be a valid box backup object.\n"); + break; + } + + MAINHELPER_END +} + -- cgit v1.2.3