Skip to content

Commit c883990

Browse files
committed
* Slightly modified html5skeleton.bat
* Added demo_sample.cpp file
1 parent 6002320 commit c883990

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

docs/demo_sample.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
}

docs/html5skeleton.bat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
@echo off
22

3+
rmdir /S /Q outdir
34
mkdir outdir
45

56
set 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

910
pause

0 commit comments

Comments
 (0)