Skip to content

Latest commit

 

History

History
19 lines (15 loc) · 1.31 KB

README.md

File metadata and controls

19 lines (15 loc) · 1.31 KB

BinHeaderGen

A simple 1 file program for loading binary files into a header file that gets compiled directly into the executable.

These headers can be used for C/C++

In the header the binary data is stored in the form of a C-string/char*/char[] with each character representing a byte since C/C++ uses ASCII for characters which uses a byte for each character. This makes it not only easy for manipulation, but also really compacts since there's no need for things like commas inbetween, as it's just the pure binary data put inbetween 2 strings that turn it into a valid header.

Want to incorporate a file into your executable without a file?
Use this!
Simply compile using your favorite C++ 20 compiler (because it's just 1 file you can literally just use g++)
Then run the executable with a parameter like this: ./<exec name> <file path>
Then it'll generate header.h (remember to change the names and use namespaces wherever you want those)
Enjoy!

Storing data this way is perfect for:

  • Avoiding file reading especially for systems where that may not be possible or for avoiding the inherent cost that comes with file reading
  • Keeping things in a single executable
  • Making sure that people don't actually break stuff by messing with files
  • Making certain data harder to access