aboutsummaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2008-10-08 16:17:26 +0000
committerMike Buland <eichlan@xagasoft.com>2008-10-08 16:17:26 +0000
commit3f1c8998166466245aee2860197fb4908e55f1a2 (patch)
treeb6d148679bbd87125f03cb723d5b59969b90c733 /src/tests
parent5883662909051e99093514483c32e2539a3cf850 (diff)
downloadlibbu++-3f1c8998166466245aee2860197fb4908e55f1a2.tar.gz
libbu++-3f1c8998166466245aee2860197fb4908e55f1a2.tar.bz2
libbu++-3f1c8998166466245aee2860197fb4908e55f1a2.tar.xz
libbu++-3f1c8998166466245aee2860197fb4908e55f1a2.zip
Ok...corrected a problem with new block allocation in nids, and it no longer
goes into an infinite loop while doing certain kinds of read. Also, it zeros out new blocks to make things easier to cope with in the hex editor, it'll probably also compress better. I also fixed Bu::MemBuf so that you can now write to arbitrary places mid-stream.
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/nids.cpp40
1 files changed, 31 insertions, 9 deletions
diff --git a/src/tests/nids.cpp b/src/tests/nids.cpp
index f50fde5..d531280 100644
--- a/src/tests/nids.cpp
+++ b/src/tests/nids.cpp
@@ -4,22 +4,44 @@
4 4
5int main( int argc, char *argv[] ) 5int main( int argc, char *argv[] )
6{ 6{
7 if( argc < 2 ) 7 if( argc < 3 )
8 { 8 {
9 printf("usage: %s <output>\n\n", argv[0] ); 9 printf("usage: %s [r|w] <output>\n\n", argv[0] );
10 return 1; 10 return 1;
11 } 11 }
12 12
13 Bu::File fOut( argv[1], Bu::File::ReadWrite ); 13 if( argv[1][0] == 'w' )
14 Bu::Nids n( fOut ); 14 {
15 Bu::File fOut( argv[2],
16 Bu::File::ReadWrite|Bu::File::Create|Bu::File::Truncate );
17 Bu::Nids n( fOut );
15 18
16// n.initialize( 120, 5 ); 19 n.initialize( 120, 1 );
20 Bu::NidsStream s = n.openStream( n.createStream() );
17 21
18 Bu::NidsStream s = n.openStream( n.createStream() ); 22 Bu::FString sBuf( 350 );
23 memset( sBuf.getStr(), 'a', 350 );
24 s.write( sBuf );
25 }
26 else if( argv[1][0] == 'r' )
27 {
28 Bu::File fOut( argv[2], Bu::File::Read );
29 Bu::Nids n( fOut );
19 30
20// Bu::FString sBuf( 350 ); 31 Bu::NidsStream s = n.openStream( 0 );
21// memset( sBuf.getStr(), 'a', 350 ); 32 char buf[75];
22// s.write( sBuf ); 33 for( int j = 0; j < 3; j++ )
34 {
35 int iRead = s.read( buf, 75 );
36 fwrite( buf, 1, iRead, stdout );
37 printf("\n(read %d chars)\n", iRead );
38 }
39 printf("Position: %ld\n", s.tell() );
40 }
41 else
42 {
43 printf("r or w, those are your choices.\n");
44 }
23 45
24 return 0; 46 return 0;
25} 47}