Skip to content

Commit c572af6

Browse files
committed
Simplified and reduced the amount of information on the console for bin2cpp
Created a text file with command line samples
1 parent 012eb7a commit c572af6

File tree

3 files changed

+32
-30
lines changed

3 files changed

+32
-30
lines changed

msvc/generate_test_files.bat

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,115 +4,115 @@ set TEST_NAME=testText10
44
set OUTDIR=.\generated_files\%TEST_NAME%
55
mkdir %OUTDIR% 1>NUL 2>NUL
66
testfilegenerator.exe --file=%OUTDIR%\%TEST_NAME%.bin --size=10 --fill=text
7-
bin2cpp.exe --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=450 --override
7+
bin2cpp.exe --noheader --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=450 --override
88

99
set TEST_NAME=testText1000
1010
set OUTDIR=.\generated_files\%TEST_NAME%
1111
mkdir %OUTDIR% 1>NUL 2>NUL
1212
testfilegenerator.exe --file=%OUTDIR%\%TEST_NAME%.bin --size=1000 --fill=text
13-
bin2cpp.exe --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=450 --override
13+
bin2cpp.exe --noheader --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=450 --override
1414

1515
set TEST_NAME=testText100000
1616
set OUTDIR=.\generated_files\%TEST_NAME%
1717
mkdir %OUTDIR% 1>NUL 2>NUL
1818
testfilegenerator.exe --file=%OUTDIR%\%TEST_NAME%.bin --size=100000 --fill=text
19-
bin2cpp.exe --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=450 --override
19+
bin2cpp.exe --noheader --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=450 --override
2020

2121
set TEST_NAME=testRandom1
2222
set OUTDIR=.\generated_files\%TEST_NAME%
2323
mkdir %OUTDIR% 1>NUL 2>NUL
2424
testfilegenerator.exe --file=%OUTDIR%\%TEST_NAME%.bin --size=100000 --fill=random --seed=1
25-
bin2cpp.exe --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=450 --override
25+
bin2cpp.exe --noheader --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=450 --override
2626

2727
set TEST_NAME=testRandom2
2828
set OUTDIR=.\generated_files\%TEST_NAME%
2929
mkdir %OUTDIR% 1>NUL 2>NUL
3030
testfilegenerator.exe --file=%OUTDIR%\%TEST_NAME%.bin --size=100000 --fill=random --seed=2
31-
bin2cpp.exe --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=450 --override
31+
bin2cpp.exe --noheader --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=450 --override
3232

3333
set TEST_NAME=testRandom3
3434
set OUTDIR=.\generated_files\%TEST_NAME%
3535
mkdir %OUTDIR% 1>NUL 2>NUL
3636
testfilegenerator.exe --file=%OUTDIR%\%TEST_NAME%.bin --size=100000 --fill=random --seed=3
37-
bin2cpp.exe --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=450 --override
37+
bin2cpp.exe --noheader --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=450 --override
3838

3939
set TEST_NAME=testRandom4
4040
set OUTDIR=.\generated_files\%TEST_NAME%
4141
mkdir %OUTDIR% 1>NUL 2>NUL
4242
testfilegenerator.exe --file=%OUTDIR%\%TEST_NAME%.bin --size=1000 --fill=random --seed=4
43-
bin2cpp.exe --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=200 --override
43+
bin2cpp.exe --noheader --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=200 --override
4444

4545
set TEST_NAME=testRandom5
4646
set OUTDIR=.\generated_files\%TEST_NAME%
4747
mkdir %OUTDIR% 1>NUL 2>NUL
4848
testfilegenerator.exe --file=%OUTDIR%\%TEST_NAME%.bin --size=1000 --fill=random --seed=5
49-
bin2cpp.exe --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=200 --override
49+
bin2cpp.exe --noheader --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=200 --override
5050

5151
set TEST_NAME=testRandom6
5252
set OUTDIR=.\generated_files\%TEST_NAME%
5353
mkdir %OUTDIR% 1>NUL 2>NUL
5454
testfilegenerator.exe --file=%OUTDIR%\%TEST_NAME%.bin --size=1000 --fill=random --seed=6
55-
bin2cpp.exe --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=200 --override
55+
bin2cpp.exe --noheader --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=200 --override
5656

5757
set TEST_NAME=testRandom7
5858
set OUTDIR=.\generated_files\%TEST_NAME%
5959
mkdir %OUTDIR% 1>NUL 2>NUL
6060
testfilegenerator.exe --file=%OUTDIR%\%TEST_NAME%.bin --size=1000 --fill=random --seed=7
61-
bin2cpp.exe --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=200 --override
61+
bin2cpp.exe --noheader --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=200 --override
6262

6363
set TEST_NAME=testRandom8
6464
set OUTDIR=.\generated_files\%TEST_NAME%
6565
mkdir %OUTDIR% 1>NUL 2>NUL
6666
testfilegenerator.exe --file=%OUTDIR%\%TEST_NAME%.bin --size=1000 --fill=random --seed=8
67-
bin2cpp.exe --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=200 --override
67+
bin2cpp.exe --noheader --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=200 --override
6868

6969
set TEST_NAME=testHtml100000
7070
set OUTDIR=.\generated_files\%TEST_NAME%
7171
mkdir %OUTDIR% 1>NUL 2>NUL
7272
testfilegenerator.exe --file=%OUTDIR%\%TEST_NAME%.bin --size=100000 --fill=html
73-
bin2cpp.exe --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=450 --override
73+
bin2cpp.exe --noheader --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=450 --override
7474

7575
set TEST_NAME=testSequential1000
7676
set OUTDIR=.\generated_files\%TEST_NAME%
7777
mkdir %OUTDIR% 1>NUL 2>NUL
7878
testfilegenerator.exe --file=%OUTDIR%\%TEST_NAME%.bin --size=1000 --fill=sequential
79-
bin2cpp.exe --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=180 --override
79+
bin2cpp.exe --noheader --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=180 --override
8080

8181
set TEST_NAME=testSequential10MB
8282
set OUTDIR=.\generated_files\%TEST_NAME%
8383
mkdir %OUTDIR% 1>NUL 2>NUL
8484
testfilegenerator.exe --file=%OUTDIR%\%TEST_NAME%.bin --size=10485760 --fill=sequential
85-
bin2cpp.exe --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=450 --override
85+
bin2cpp.exe --noheader --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=450 --override
8686

8787
REM set TEST_NAME=testSequential20MB
8888
REM set OUTDIR=.\generated_files\%TEST_NAME%
8989
REM mkdir %OUTDIR% 1>NUL 2>NUL
9090
REM testfilegenerator.exe --file=%OUTDIR%\%TEST_NAME%.bin --size=20971520 --fill=sequential
91-
REM bin2cpp.exe --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=450 --override
91+
REM bin2cpp.exe --noheader --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=450 --override
9292
REM
9393
REM set TEST_NAME=testSequential30MB
9494
REM set OUTDIR=.\generated_files\%TEST_NAME%
9595
REM mkdir %OUTDIR% 1>NUL 2>NUL
9696
REM testfilegenerator.exe --file=%OUTDIR%\%TEST_NAME%.bin --size=31457280 --fill=sequential
97-
REM bin2cpp.exe --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=450 --override
97+
REM bin2cpp.exe --noheader --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=450 --override
9898

9999
set TEST_NAME=testIssue12
100100
set OUTDIR=.\generated_files\%TEST_NAME%
101101
mkdir %OUTDIR% 1>NUL 2>NUL
102102
testfilegenerator.exe --file=%OUTDIR%\%TEST_NAME%.bin --size=100000 --fill=random --seed=3
103-
bin2cpp.exe --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=450 --override
103+
bin2cpp.exe --noheader --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=450 --override
104104

105105
set TEST_NAME=testIssue12Mini
106106
set OUTDIR=.\generated_files\%TEST_NAME%
107107
mkdir %OUTDIR% 1>NUL 2>NUL
108108
testfilegenerator.exe --file=%OUTDIR%\%TEST_NAME%.bin --size=100 --fill=random --seed=3 --skip=47240
109-
bin2cpp.exe --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=10 --override
109+
bin2cpp.exe --noheader --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=10 --override
110110

111111
set TEST_NAME=testIssue13
112112
set OUTDIR=.\generated_files\%TEST_NAME%
113113
mkdir %OUTDIR% 1>NUL 2>NUL
114114
echo testfilegenerator.exe --file=%OUTDIR%\%TEST_NAME%.bin --size=1000 --fill=random --seed=1
115115
testfilegenerator.exe --file=%OUTDIR%\%TEST_NAME%.bin --size=1000 --fill=random --seed=1
116-
bin2cpp.exe --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=100 --override
116+
bin2cpp.exe --noheader --file=%OUTDIR%\%TEST_NAME%.bin --output=%OUTDIR% --headerfile=_%TEST_NAME%.h --identifier=%TEST_NAME% --chunksize=100 --override
117117

118118
dir >NUL

src/bin2cpp.samples.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
--file=.\generated_files\testText1000\testText1000.bin --output=.\generated_files\testText1000 --headerfile=_testText1000.h --identifier=testText1000 --chunksize=450 --override
2+
--file=.\generated_files\testSequential1000\testSequential1000.bin --output=.\generated_files\testSequential1000 --headerfile=_testSequential1000.h --identifier=testSequential1000 --chunksize=180 --override
3+
--file=C:\Temp\foobar.bin --output=C:\Temp --headerfile=_testFoo.h --identifier=testFoo --override
4+
--file=C:\Temp\foobar.bin --output=C:\Temp --headerfile=_testFoo.h --identifier=testFoo --override --noheader

src/main.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525

2626
void printHeader()
2727
{
28-
printf("bin2cpp v%s\n", bin2cpp::getVersionString() );
29-
printf("Convert binary files into C++ source code.\n");
28+
printf("bin2cpp v%s - Convert binary files into C++ source code.\n", bin2cpp::getVersionString() );
3029
printf("Copyright (C) 2013-%d end2endzone.com. All rights reserved.\n", bin2cpp::getCopyrightYear());
3130
printf("bin2cpp is open source software, see http://github.com/end2endzone/bin2cpp \n");
3231
}
@@ -208,14 +207,13 @@ int main(int argc, char* argv[])
208207
if (overrideExisting)
209208
overrideInfo = " overriding existing files";
210209
bin2cpp::log(bin2cpp::LOG_INFO, "Embedding \"%s\" into \"%s\"%s%s...", inputFilename.c_str(), headerFilename.c_str(), chunkInfo.c_str(), overrideInfo.c_str());
211-
bin2cpp::log(bin2cpp::LOG_INFO, "Using '%s' generator...", generator->getName());
212-
210+
213211
//generate header
214-
bin2cpp::log(bin2cpp::LOG_INFO, "Generating header file...");
212+
std::string outputHeaderPath = outputFolder + "\\" + headerFilename;
213+
bin2cpp::log(bin2cpp::LOG_INFO, "Writing header file \"%s\"...", outputHeaderPath.c_str());
215214
bin2cpp::ErrorCodes headerResult = bin2cpp::ErrorCodes::Success;
216215

217216
//check if header file already exists
218-
std::string outputHeaderPath = outputFolder + "\\" + headerFilename;
219217
if (bin2cpp::fileExists(outputHeaderPath.c_str()))
220218
{
221219
if (!overrideExisting)
@@ -257,7 +255,7 @@ int main(int argc, char* argv[])
257255
}
258256
if (headerResult == bin2cpp::ErrorCodes::Success)
259257
{
260-
bin2cpp::log(bin2cpp::LOG_INFO, "done");
258+
//OK
261259
}
262260
else if (headerResult == bin2cpp::ErrorCodes::OutputFilesSkipped)
263261
{
@@ -271,14 +269,14 @@ int main(int argc, char* argv[])
271269
}
272270

273271
//generate cpp
274-
bin2cpp::log(bin2cpp::LOG_INFO, "Generating cpp file...");
272+
std::string outputCppPath = outputFolder + "\\" + headerFilename;
273+
bin2cpp::strReplace(outputCppPath, ".h", ".cpp");
274+
bin2cpp::log(bin2cpp::LOG_INFO, "Writing cpp file \"%s\"...", outputCppPath.c_str());
275275
bin2cpp::ErrorCodes cppResult = bin2cpp::ErrorCodes::Success;
276276

277277
//check if cpp file already exists
278-
std::string outputCppPath = outputFolder + "\\" + headerFilename;
279278
std::string cppFilename = headerFilename;
280279
bin2cpp::strReplace(cppFilename, ".h", ".cpp");
281-
bin2cpp::strReplace(outputCppPath, ".h", ".cpp");
282280
if (bin2cpp::fileExists(outputCppPath.c_str()))
283281
{
284282
if (!overrideExisting)
@@ -320,7 +318,7 @@ int main(int argc, char* argv[])
320318
}
321319
if (cppResult == bin2cpp::ErrorCodes::Success)
322320
{
323-
bin2cpp::log(bin2cpp::LOG_INFO, "done");
321+
//OK
324322
}
325323
else if (cppResult == bin2cpp::ErrorCodes::OutputFilesSkipped)
326324
{

0 commit comments

Comments
 (0)