File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed
Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change 1+ #include < stdio.h>
2+ #include < string>
3+ #include " base64.h"
4+ #include " resourcehtml5skeleton.h" // a single include file is all you need
5+
6+ int main (int argc, char * argv[])
7+ {
8+ // get a reference to the embedded file
9+ const bin2cpp::File & resource = bin2cpp::getHtmlSampleFile ();
10+
11+ // print information about the file.
12+ printf (" Embedded file '%s' is %d bytes long.\n " , resource.getFilename (), resource.getSize ());
13+ printf (" The MD5 of the file is %s.\n " , resource.getMd5 ());
14+
15+ // Saving content back to a file.
16+ printf (" Saving embedded file to 'html5skeleton_copy.html'...\n " );
17+ bool saved = resource.save (" html5skeleton_copy.html" );
18+ if (saved)
19+ printf (" saved\n " );
20+ else
21+ printf (" failed\n " );
22+
23+ // encoding content as base64
24+ char * buffer = resource.newBuffer (); // returns a new buffer with a copy of the file. Ownership is transfered to the local function
25+ size_t bufferSize = resource.getSize ();
26+ std::string encodedFile = toBase64 (buffer, bufferSize); // binary to base64 encoder
27+ delete buffer; // delete allocatd buffer from newBuffer()
28+ buffer = NULL ;
29+
30+ // do something with the base64 encoded file
31+ // ...
32+
33+ return 0 ;
34+ }
Original file line number Diff line number Diff line change 11@ echo off
22
3+ rmdir /S /Q outdir
34mkdir outdir
45
56set path = %PATH% ;%cd% \..\msvc\Win32\Release
67
7- bin2cpp.exe --file=html5skeleton.html --output=.\outdir --headerfile=resourcehtml5skeleton.h --identifier=HtmlSample --chunksize=50 --override
8+ bin2cpp.exe --file=html5skeleton.html --output=.\outdir --headerfile=resourcehtml5skeleton.h --identifier=HtmlSample --chunksize=50
89
910pause
You can’t perform that action at this time.
0 commit comments