generate_binary.cpp 887 B

1234567891011121314151617181920212223242526272829303132333435
  1. #include <fstream>
  2. #include <ios>
  3. #include <string>
  4. static unsigned char const long_contents[] = {
  5. #include "long.c.txt"
  6. };
  7. int main(int argc, char** argv)
  8. {
  9. if (argc != 3) {
  10. return 1;
  11. }
  12. std::string name = argv[1];
  13. std::ofstream fout(argv[2], std::ios::out | std::ios::binary);
  14. if (name == "basic") {
  15. fout.write("\xFC\xFD\xFE\xFF\x00\x01\x02\x03", 8);
  16. } else if (name == "empty") {
  17. // Write nothing
  18. } else if (name == "text_lf") {
  19. fout << "All work and no play makes Jack a dull boy.\n";
  20. } else if (name == "text_crlf") {
  21. fout << "All work and no play makes Jack a dull boy.\r\n";
  22. } else if (name == "text_align") {
  23. fout << "This exactly 32 characters long!";
  24. } else if (name == "long") {
  25. fout.write(reinterpret_cast<char const*>(long_contents),
  26. sizeof(long_contents));
  27. }
  28. fout.flush();
  29. fout.close();
  30. return 0;
  31. }