diff options
author | Mike Buland <eichlan@xagasoft.com> | 2009-06-18 19:57:12 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2009-06-18 19:57:12 +0000 |
commit | 158d215b33d5b5bf07f73bb7547aae1fb12593b3 (patch) | |
tree | e4a0204370bc295509d1299c603dff13efe00cc3 /src/tests/base64.cpp | |
parent | ededeea60b8dca5320e741c7859b54f32ad75cf7 (diff) | |
download | libbu++-158d215b33d5b5bf07f73bb7547aae1fb12593b3.tar.gz libbu++-158d215b33d5b5bf07f73bb7547aae1fb12593b3.tar.bz2 libbu++-158d215b33d5b5bf07f73bb7547aae1fb12593b3.tar.xz libbu++-158d215b33d5b5bf07f73bb7547aae1fb12593b3.zip |
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.
Diffstat (limited to 'src/tests/base64.cpp')
-rw-r--r-- | src/tests/base64.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
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 @@ | |||
1 | #include "bu/file.h" | ||
2 | #include "bu/base64.h" | ||
3 | |||
4 | int main( int argc, char *argv[] ) | ||
5 | { | ||
6 | argc--,argv++; | ||
7 | |||
8 | if( argc < 3 ) | ||
9 | return 0; | ||
10 | |||
11 | if( argv[0][0] == 'e' ) | ||
12 | { | ||
13 | argv++; | ||
14 | Bu::File fIn( argv[0], Bu::File::Read ); | ||
15 | Bu::File fOut( argv[1], Bu::File::WriteNew ); | ||
16 | Bu::Base64 bOut( fOut, Bu::Base64::Write ); | ||
17 | |||
18 | char buf[900]; | ||
19 | for(;;) | ||
20 | { | ||
21 | int iRead = fIn.read( buf, 900 ); | ||
22 | bOut.write( buf, iRead ); | ||
23 | if( iRead < 900 ) | ||
24 | break; | ||
25 | } | ||
26 | } | ||
27 | else if( argv[0][0] == 'd' ) | ||
28 | { | ||
29 | argv++; | ||
30 | Bu::File fIn( argv[0], Bu::File::Read ); | ||
31 | Bu::File fOut( argv[1], Bu::File::WriteNew ); | ||
32 | Bu::Base64 bIn( fIn, Bu::Base64::Read ); | ||
33 | |||
34 | char buf[900]; | ||
35 | for(;;) | ||
36 | { | ||
37 | int iRead = bIn.read( buf, 900 ); | ||
38 | fOut.write( buf, iRead ); | ||
39 | if( iRead < 900 ) | ||
40 | break; | ||
41 | } | ||
42 | } | ||
43 | |||
44 | return 0; | ||
45 | } | ||