From 0befcc026be9e4f6c40f8771c7f26f767ebddbf7 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 30 Sep 2024 11:50:17 -0700 Subject: Erasing streams works, stream map building works. --- src/tools/myriad.cpp | 59 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 47 insertions(+), 12 deletions(-) (limited to 'src/tools') diff --git a/src/tools/myriad.cpp b/src/tools/myriad.cpp index 346cd85..0dd9840 100644 --- a/src/tools/myriad.cpp +++ b/src/tools/myriad.cpp @@ -94,6 +94,49 @@ Bu::Formatter &operator>>( Bu::Formatter &f, Mode & /*e*/ ) return f; } +void printMap( const Bu::BitString &bs ) +{ + for( int j = 0; j < bs.getSize(); j++ ) + { + if( j>0 && (j%50) == 0 ) + Bu::println(""); + if( bs.getBit( j ) ) + Bu::print("#"); + else + Bu::print("-"); + } + Bu::println("\n"); +} + +void printMap( const Bu::Array &bm ) +{ + int iBigest = 0; + for( int j = 0; j < bm.getSize(); j++ ) + { + if( iBigest < bm[j] ) + iBigest = bm[j]; + } + int iWidth = Bu::String("%1").arg( iBigest ).end().getSize(); + Bu::String sEmpty; + for( int j = 0; j < iWidth; j++ ) + { + sEmpty += '-'; + } + int iBreakAt = 60/(iWidth+1); + for( int j = 0; j < bm.getSize(); j++ ) + { + if( j>0 && (j%iBreakAt) == 0 ) + Bu::println(""); + + if( bm[j] < 0 ) + Bu::print("%1 ").arg( sEmpty, Bu::Fmt(2).right().fill(' ')); + else + Bu::print("%1 ").arg( bm[j], Bu::Fmt(2).right().fill(' ')); + + } + Bu::println("\n"); +} + int main( int argc, char *argv[] ) { Options opts( argc, argv ); @@ -168,6 +211,8 @@ int main( int argc, char *argv[] ) File fOut( opts.sFile, File::Write|File::Read ); Myriad m( fOut ); m.erase( opts.iStream ); + printMap( m.buildBlockUseMap() ); + printMap( m.buildBlockMap() ); } break; @@ -273,17 +318,8 @@ int main( int argc, char *argv[] ) { File fIn( opts.sFile, File::Write|File::Read ); Myriad m( fIn ); -/* Bu::BitString bs = m.getBlocksUsed(); - for( int j = 0; j < bs.getSize(); j++ ) - { - if( j>0 && (j%50) == 0 ) - Bu::println(""); - if( bs.getBit( j ) ) - Bu::print("#"); - else - Bu::print("-"); - }*/ - Bu::println("\n"); + printMap( m.buildBlockUseMap() ); + printMap( m.buildBlockMap() ); } break; @@ -295,4 +331,3 @@ int main( int argc, char *argv[] ) return 0; } - -- cgit v1.2.3