diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-05-24 03:04:56 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-05-24 03:04:56 +0000 |
commit | 0643b03b0ca30ef7c413a00bcd4eb17026dce568 (patch) | |
tree | 9a341e18af31ffcd5085cc30faa5c6511b4086dc | |
parent | 20ee81a7b2d44ec985e99b4ee1bcd08fa25175d3 (diff) | |
download | libbu++-0643b03b0ca30ef7c413a00bcd4eb17026dce568.tar.gz libbu++-0643b03b0ca30ef7c413a00bcd4eb17026dce568.tar.bz2 libbu++-0643b03b0ca30ef7c413a00bcd4eb17026dce568.tar.xz libbu++-0643b03b0ca30ef7c413a00bcd4eb17026dce568.zip |
bin2cpp supports lzma compression. I need to modify the headers so it only
includes headers for the things you use.
-rw-r--r-- | default.bld | 2 | ||||
-rw-r--r-- | src/tools/bin2cpp.cpp | 12 |
2 files changed, 12 insertions, 2 deletions
diff --git a/default.bld b/default.bld index 56634fe..6b6bbc3 100644 --- a/default.bld +++ b/default.bld | |||
@@ -183,7 +183,7 @@ target "myriadfs" | |||
183 | 183 | ||
184 | target "bin2cpp" | 184 | target "bin2cpp" |
185 | { | 185 | { |
186 | LDFLAGS += "-lz -lbz2"; | 186 | LDFLAGS += "-lz -lbz2 -llzma"; |
187 | } | 187 | } |
188 | 188 | ||
189 | // | 189 | // |
diff --git a/src/tools/bin2cpp.cpp b/src/tools/bin2cpp.cpp index 53da0b5..15ef73d 100644 --- a/src/tools/bin2cpp.cpp +++ b/src/tools/bin2cpp.cpp | |||
@@ -3,6 +3,7 @@ | |||
3 | #include <bu/file.h> | 3 | #include <bu/file.h> |
4 | #include <bu/deflate.h> | 4 | #include <bu/deflate.h> |
5 | #include <bu/bzip2.h> | 5 | #include <bu/bzip2.h> |
6 | #include <bu/lzma.h> | ||
6 | #include <bu/base64.h> | 7 | #include <bu/base64.h> |
7 | #include <bu/hex.h> | 8 | #include <bu/hex.h> |
8 | #include <bu/streamstack.h> | 9 | #include <bu/streamstack.h> |
@@ -20,7 +21,7 @@ public: | |||
20 | addOption( sClass, 'c', "Class name [default=\"Datafiles\"]"); | 21 | addOption( sClass, 'c', "Class name [default=\"Datafiles\"]"); |
21 | addOption( sOutBase, 'o', "Output base filename [defaults to classname]"); | 22 | addOption( sOutBase, 'o', "Output base filename [defaults to classname]"); |
22 | addOption( sOutDir, 'd', "Output directory [defaults to current dir]"); | 23 | addOption( sOutDir, 'd', "Output directory [defaults to current dir]"); |
23 | addOption( slot(this, &Options::addFilter), 'f', "Add filter: deflate, bzip2, base64, hex"); | 24 | addOption( slot(this, &Options::addFilter), 'f', "Add filter: deflate, bzip2, lzma, base64, hex"); |
24 | setNonOption( slot(this, &Options::addInput) ); | 25 | setNonOption( slot(this, &Options::addInput) ); |
25 | addHelpOption(); | 26 | addHelpOption(); |
26 | 27 | ||
@@ -90,6 +91,7 @@ int main( int argc, char *argv[] ) | |||
90 | << "#include <bu/deflate.h>" << fSrc.nl | 91 | << "#include <bu/deflate.h>" << fSrc.nl |
91 | << "#include <bu/bzip2.h>" << fSrc.nl | 92 | << "#include <bu/bzip2.h>" << fSrc.nl |
92 | << "#include <bu/base64.h>" << fSrc.nl | 93 | << "#include <bu/base64.h>" << fSrc.nl |
94 | << "#include <bu/lzma.h>" << fSrc.nl | ||
93 | << "#include <bu/hex.h>" << fSrc.nl | 95 | << "#include <bu/hex.h>" << fSrc.nl |
94 | << "#include <bu/strfilter.h>" << fSrc.nl | 96 | << "#include <bu/strfilter.h>" << fSrc.nl |
95 | << "#include <bu/staticmembuf.h>" << fSrc.nl << fSrc.nl | 97 | << "#include <bu/staticmembuf.h>" << fSrc.nl << fSrc.nl |
@@ -120,6 +122,12 @@ int main( int argc, char *argv[] ) | |||
120 | sFltDesc.prepend("b"); | 122 | sFltDesc.prepend("b"); |
121 | hFilters.insert('b', true ); | 123 | hFilters.insert('b', true ); |
122 | } | 124 | } |
125 | else if( *f == "lzma" ) | ||
126 | { | ||
127 | sDat = encodeStr<Lzma>( sDat ); | ||
128 | sFltDesc.prepend("l"); | ||
129 | hFilters.insert('l', true ); | ||
130 | } | ||
123 | else if( *f == "base64" ) | 131 | else if( *f == "base64" ) |
124 | { | 132 | { |
125 | sDat = encodeStr<Base64>( sDat ); | 133 | sDat = encodeStr<Base64>( sDat ); |
@@ -181,6 +189,8 @@ int main( int argc, char *argv[] ) | |||
181 | fSrc << "\t\t\tcase 'd': s->pushFilter<Bu::Deflate>(); break;" << fSrc.nl; | 189 | fSrc << "\t\t\tcase 'd': s->pushFilter<Bu::Deflate>(); break;" << fSrc.nl; |
182 | if( hFilters.has('b') ) | 190 | if( hFilters.has('b') ) |
183 | fSrc << "\t\t\tcase 'b': s->pushFilter<Bu::BZip2>(); break;" << fSrc.nl; | 191 | fSrc << "\t\t\tcase 'b': s->pushFilter<Bu::BZip2>(); break;" << fSrc.nl; |
192 | if( hFilters.has('l') ) | ||
193 | fSrc << "\t\t\tcase 'l': s->pushFilter<Bu::Lzma>(); break;" << fSrc.nl; | ||
184 | if( hFilters.has('6') ) | 194 | if( hFilters.has('6') ) |
185 | fSrc << "\t\t\tcase '6': s->pushFilter<Bu::Base64>(); break;" << fSrc.nl; | 195 | fSrc << "\t\t\tcase '6': s->pushFilter<Bu::Base64>(); break;" << fSrc.nl; |
186 | if( hFilters.has('h') ) | 196 | if( hFilters.has('h') ) |