diff options
author | Chris Wilson <chris+github@qwirx.com> | 2008-04-04 21:59:29 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2008-04-04 21:59:29 +0000 |
commit | 3661f3624acc46590d5504fda4f8714255fb2c8e (patch) | |
tree | e2cd17e19718d3f46944979a23e4c93dcf92584b /bin/bbstoreaccounts | |
parent | 2f8d0c29536cdb306b525b78638727da4ead0022 (diff) |
Tailorization
Import of the upstream sources from
Repository: http://localhost:8000/
Kind: hg
Revision: 7807b7768163f1c2537756abe5416063989cebb1
Original author: tailor@rocio.int.aidworld.org
Date: 2008-03-16 19:44:36+00:00
Diffstat (limited to 'bin/bbstoreaccounts')
-rw-r--r-- | bin/bbstoreaccounts/bbstoreaccounts.cpp | 56 |
1 files changed, 25 insertions, 31 deletions
diff --git a/bin/bbstoreaccounts/bbstoreaccounts.cpp b/bin/bbstoreaccounts/bbstoreaccounts.cpp index d1740d81..6f079d30 100644 --- a/bin/bbstoreaccounts/bbstoreaccounts.cpp +++ b/bin/bbstoreaccounts/bbstoreaccounts.cpp @@ -13,11 +13,8 @@ #include <stdio.h> #include <sys/types.h> #include <limits.h> - -#include <algorithm> -#include <iostream> -#include <ostream> #include <vector> +#include <algorithm> #include "BoxPortsAndFiles.h" #include "BackupStoreConfigVerify.h" @@ -65,10 +62,22 @@ int BlockSizeOfDiscSet(int DiscSet) return controller.GetDiscSet(DiscSet).GetBlockSize(); } -std::string BlockSizeToString(int64_t Blocks, int64_t MaxBlocks, int DiscSet) +const char *BlockSizeToString(int64_t Blocks, int DiscSet) { - return FormatUsageBar(Blocks, Blocks * BlockSizeOfDiscSet(DiscSet), - MaxBlocks * BlockSizeOfDiscSet(DiscSet)); + // Not reentrant, nor can be used in the same function call twice, etc. + static char string[256]; + + // Work out size in Mb. + double mb = (Blocks * BlockSizeOfDiscSet(DiscSet)) / (1024.0*1024.0); + + // Format string +#ifdef WIN32 + sprintf(string, "%I64d (%.2fMb)", Blocks, mb); +#else + sprintf(string, "%lld (%.2fMb)", Blocks, mb); +#endif + + return string; } int64_t SizeStringToBlocks(const char *string, int DiscSet) @@ -220,30 +229,15 @@ int AccountInfo(Configuration &rConfig, int32_t ID) std::auto_ptr<BackupStoreInfo> info(BackupStoreInfo::Load(ID, rootDir, discSet, true /* ReadOnly */)); // Then print out lots of info - std::cout << FormatUsageLineStart("Account ID") << - BOX_FORMAT_ACCOUNT(ID) << std::endl; - std::cout << FormatUsageLineStart("Last object ID") << - BOX_FORMAT_OBJECTID(info->GetLastObjectIDUsed()) << std::endl; - std::cout << FormatUsageLineStart("Used") << - BlockSizeToString(info->GetBlocksUsed(), - info->GetBlocksHardLimit(), discSet) << std::endl; - std::cout << FormatUsageLineStart("Old files") << - BlockSizeToString(info->GetBlocksInOldFiles(), - info->GetBlocksHardLimit(), discSet) << std::endl; - std::cout << FormatUsageLineStart("Deleted files") << - BlockSizeToString(info->GetBlocksInDeletedFiles(), - info->GetBlocksHardLimit(), discSet) << std::endl; - std::cout << FormatUsageLineStart("Directories") << - BlockSizeToString(info->GetBlocksInDirectories(), - info->GetBlocksHardLimit(), discSet) << std::endl; - std::cout << FormatUsageLineStart("Soft limit") << - BlockSizeToString(info->GetBlocksSoftLimit(), - info->GetBlocksHardLimit(), discSet) << std::endl; - std::cout << FormatUsageLineStart("Hard limit") << - BlockSizeToString(info->GetBlocksHardLimit(), - info->GetBlocksHardLimit(), discSet) << std::endl; - std::cout << FormatUsageLineStart("Client store marker") << - info->GetLastObjectIDUsed() << std::endl; + printf(" Account ID: %08x\n", ID); + printf(" Last object ID: %lld\n", info->GetLastObjectIDUsed()); + printf(" Blocks used: %s\n", BlockSizeToString(info->GetBlocksUsed(), discSet)); + printf(" Blocks used by old files: %s\n", BlockSizeToString(info->GetBlocksInOldFiles(), discSet)); + printf("Blocks used by deleted files: %s\n", BlockSizeToString(info->GetBlocksInDeletedFiles(), discSet)); + printf(" Blocks used by directories: %s\n", BlockSizeToString(info->GetBlocksInDirectories(), discSet)); + printf(" Block soft limit: %s\n", BlockSizeToString(info->GetBlocksSoftLimit(), discSet)); + printf(" Block hard limit: %s\n", BlockSizeToString(info->GetBlocksHardLimit(), discSet)); + printf(" Client store marker: %lld\n", info->GetClientStoreMarker()); return 0; } |