Skip to content

All the small things #41

@end2endzone

Description

@end2endzone

The following task should be completed :

  • When generating the FileManager files (header and cpp files) from a directory, the header reads Source code for file 'New Text Document.txt', last modified 1619101267. which his incorrect. It should read Source code for file 'FileManager.h', last modified 1619101267.
  • In help message, replace "as a C++ source code" by "as C++ source code"
  • Find out why generated files with --managerfile do not require --registerfile flag. They do automatically registers. Maybe update documentation saying that flag '--registerfile' is automatically set if flag '--managerfile' is specified ?
  • Validate updating a generated file if the input file has changed. Is there already a unit test for that ?
  • In help message, explain that 'headerfile' and 'identifier' parameters are automatically calculated when using 'dir'.
  • Update "Command Line Usage" in readme.md. It is out of date.
  • Create sections for each examples in README.md.
  • Rename https://github.com/end2endzone/bin2cpp#example to "Example 1 - Convert a single html file to c++ source code."
  • Rename section "Input File:" (and the first line) to "Input File: helloworld.html" (drop the html5 and skeleton part)
  • Change the command line to: bin2cpp.exe --file=helloworld.html --output=.\outdir --headerfile=generated_helloworld.h --identifier=HelloWorldHtml --chunksize=50
  • Rename "File file_html5skeleton.h" to Output file: generated_helloworld.h"
  • Rename "File file_html5skeleton.cpp" to Output file: generated_helloworld.cpp"
  • Rename "Code sample (using embedded files)" to "At runtime, show file properties and save/export data back to a file".
  • Create another example: "Example 2 - Convert multiple files in a single directory to c++ source code."
  • Add an examples with --dir using FileManager option to extract all files.
  • Create an example with lena image ?
  • The README.md file do not explain how bin2cpp is indented to be used. More documentation and examples should be created.
  • In the header of the readme, a note should be added to explain something like "When executed, bin2cpp takes a binary file and outputs c++ code (a function) that when called allows a c++ program to retrieve the content of the input binary file".
  • The project description "bin2cpp converts text or binary files to C++ files (*.h, *.cpp) for easy access within the code." should also appears in the README.md file.
  • A section called bin2cpp worlflow which explains how one can use bin2cpp to embed a binary file could be created.

Code sample for the --dir example :

#include "../../demo/generated_files.2/FileManager.h"

int main(int argc, char* argv[])
{
  bin2cpp::FileManager & mgr = bin2cpp::FileManager::getInstance();

  //Print information about all files generated with "--managerfile" or --registerfile flags.
  size_t num_files = mgr.getFileCount();
  printf("Found %lu embedded files...\n", num_files);

  //Listing files.
  for(size_t i=0; i<num_files; i++)
  {
    const bin2cpp::File * file = mgr.getFile(i);
    printf("  File '%s', %lu bytes\n", file->getFilename(), file->getSize());
  }

  //Saving content back to files.
  const char * temp_dir = getenv("TEMP");
  printf("Saving embedded files to directory '%s'...\n", temp_dir);
  bool saved = mgr.saveFiles(temp_dir);
  if (saved)
    printf("saved\n");
  else
    printf("failed\n");

  return 0;
}


Found 4 embedded files...
  File 'New Bitmap Image.bmp', 17994 bytes
  File 'New Microsoft Excel Worksheet.xlsx', 6203 bytes
  File 'New Microsoft Word Document.docx', 11340 bytes
  File 'New Text Document.txt', 17 bytes
Saving embedded files to directory 'C:\Users\antoine\AppData\Local\Temp'...
saved
Press any key to continue . . .

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions