[Box Backup-commit] COMMIT r2125 - box/trunk/bin/bbstoreaccounts
boxbackup-dev@fluffy.co.uk
boxbackup-dev@fluffy.co.uk
Fri, 4 Apr 2008 21:59:37 +0000 (UTC)
Author: chris
Date: 2008-04-04 21:59:36 +0000 (Fri, 04 Apr 2008)
New Revision: 2125
Modified:
box/trunk/bin/bbstoreaccounts/bbstoreaccounts.cpp
Log:
[hg-svn @ 9203d99fcfd5a6c90994bda6397aa55d9ac64458]
Use streams to format block counts and sizes in bbstoreaccounts, merges [2088].
Original author: chris@rocio.int.aidworld.org
Date: 2008-03-16 19:50:06+00:00
Modified: box/trunk/bin/bbstoreaccounts/bbstoreaccounts.cpp
===================================================================
--- box/trunk/bin/bbstoreaccounts/bbstoreaccounts.cpp 2008-04-04 21:59:29 UTC (rev 2124)
+++ box/trunk/bin/bbstoreaccounts/bbstoreaccounts.cpp 2008-04-04 21:59:36 UTC (rev 2125)
@@ -62,22 +62,16 @@
return controller.GetDiscSet(DiscSet).GetBlockSize();
}
-const char *BlockSizeToString(int64_t Blocks, int DiscSet)
+std::string BlockSizeToString(int64_t Blocks, int 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;
+ std::ostringstream buf;
+ buf << Blocks << " blocks " << std::fixed << std::setprecision(2) <<
+ std::showpoint << "(" << mb << " MB)";
+ return buf.str();
}
int64_t SizeStringToBlocks(const char *string, int DiscSet)
@@ -231,12 +225,12 @@
// Then print out lots of info
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(" Blocks used: %s\n", BlockSizeToString(info->GetBlocksUsed(), discSet).c_str());
+ printf(" Blocks used by old files: %s\n", BlockSizeToString(info->GetBlocksInOldFiles(), discSet).c_str());
+ printf("Blocks used by deleted files: %s\n", BlockSizeToString(info->GetBlocksInDeletedFiles(), discSet).c_str());
+ printf(" Blocks used by directories: %s\n", BlockSizeToString(info->GetBlocksInDirectories(), discSet).c_str());
+ printf(" Block soft limit: %s\n", BlockSizeToString(info->GetBlocksSoftLimit(), discSet).c_str());
+ printf(" Block hard limit: %s\n", BlockSizeToString(info->GetBlocksHardLimit(), discSet).c_str());
printf(" Client store marker: %lld\n", info->GetClientStoreMarker());
return 0;