From 0c14721b0df0a114f44c27d868703b127eecc9ed Mon Sep 17 00:00:00 2001 From: ksherlock Date: Fri, 11 Dec 2009 05:31:13 +0000 Subject: [PATCH] git-svn-id: https://profuse.googlecode.com/svn/branches/v2@144 aa027e90-d47c-11dd-86d7-074df07e0730 --- pascal/FileMan.cpp | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/pascal/FileMan.cpp b/pascal/FileMan.cpp index 0452653..47f0afe 100644 --- a/pascal/FileMan.cpp +++ b/pascal/FileMan.cpp @@ -57,11 +57,18 @@ const char *FileType(unsigned ft) return ""; } +void printUnusedRecord(unsigned block, unsigned size) +{ + std::printf("< UNUSED > %4u %4u\n", size, block); +} + void list(Pascal::VolumeEntry *volume, bool extended) { unsigned fileCount = volume->fileCount(); unsigned used = volume->blocks(); unsigned max = 0; + unsigned volumeSize = volume->volumeBlocks(); + unsigned lastBlock = volume->lastBlock(); std::fprintf(stdout, "%s:\n", volume->name()); @@ -74,10 +81,22 @@ void list(Pascal::VolumeEntry *volume, bool extended) //TODO -- include gaps. + if (lastBlock != e->firstBlock()) + { + unsigned size = e->firstBlock() - lastBlock; + max = std::max(max, size); + + if (extended) + { + printUnusedRecord(lastBlock, size); + } + } + lastBlock = e->lastBlock(); + if (extended) { - std::fprintf(stdout, "%-15s %4u %2u-%s-%2u %5u %5u %s\n", + std::printf("%-15s %4u %2u-%s-%2u %5u %5u %s\n", e->name(), e->blocks(), dt.day(), @@ -91,7 +110,7 @@ void list(Pascal::VolumeEntry *volume, bool extended) } else { - std::fprintf(stdout, "%-15s %4u %2u-%s-%2u\n", + std::printf("%-15s %4u %2u-%s-%2u\n", e->name(), e->blocks(), dt.day(), @@ -100,10 +119,13 @@ void list(Pascal::VolumeEntry *volume, bool extended) ); } used += e->blocks(); - max = std::max(max, e->blocks()); } - // TODO -- largest refers to largest unused block, - // not the largest file. + + if (extended && (lastBlock != volumeSize)) + { + printUnusedRecord(lastBlock, volumeSize - lastBlock); + } + std::fprintf(stdout, "%u/%u files, " @@ -112,10 +134,10 @@ void list(Pascal::VolumeEntry *volume, bool extended) "%u in largest\n", fileCount, fileCount, used, - volume->volumeBlocks() - used, + volumeSize- used, max ); - + }