From 158d215b33d5b5bf07f73bb7547aae1fb12593b3 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 18 Jun 2009 19:57:12 +0000 Subject: Added a new enum value to Bu::File, Bu::File::WriteNew which combines Write, Truncate, and Create, the flags used most commonly when writing a new file. Also added the Bu::Base64 filter class, it does base64 encoding and decoding, it may need a couple more interfaces added, but for the most part, it's solid. --- src/tests/base64.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/tests/base64.cpp (limited to 'src/tests') diff --git a/src/tests/base64.cpp b/src/tests/base64.cpp new file mode 100644 index 0000000..4f2d68b --- /dev/null +++ b/src/tests/base64.cpp @@ -0,0 +1,45 @@ +#include "bu/file.h" +#include "bu/base64.h" + +int main( int argc, char *argv[] ) +{ + argc--,argv++; + + if( argc < 3 ) + return 0; + + if( argv[0][0] == 'e' ) + { + argv++; + Bu::File fIn( argv[0], Bu::File::Read ); + Bu::File fOut( argv[1], Bu::File::WriteNew ); + Bu::Base64 bOut( fOut, Bu::Base64::Write ); + + char buf[900]; + for(;;) + { + int iRead = fIn.read( buf, 900 ); + bOut.write( buf, iRead ); + if( iRead < 900 ) + break; + } + } + else if( argv[0][0] == 'd' ) + { + argv++; + Bu::File fIn( argv[0], Bu::File::Read ); + Bu::File fOut( argv[1], Bu::File::WriteNew ); + Bu::Base64 bIn( fIn, Bu::Base64::Read ); + + char buf[900]; + for(;;) + { + int iRead = bIn.read( buf, 900 ); + fOut.write( buf, iRead ); + if( iRead < 900 ) + break; + } + } + + return 0; +} -- cgit v1.2.3