2
0

ParseXnb.cpp 841 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include "stdafx.h"
  2. #include "ContentReader.h"
  3. int main(int argc, char const* argv[])
  4. {
  5. // Make sure we got a single filename commandline argument.
  6. if (argc != 2)
  7. {
  8. printf("Usage: ParseXnb <filename>.xnb\n");
  9. return 1;
  10. }
  11. // Open the file.
  12. FILE* file;
  13. if (fopen_s(&file, argv[1], "rb") != 0)
  14. {
  15. printf("Error: can't open '%s'.\n", argv[1]);
  16. return 1;
  17. }
  18. // Instantate the XNB reader.
  19. TypeReaderManager typeReaderManager;
  20. typeReaderManager.RegisterStandardTypes();
  21. ContentReader reader(file, &typeReaderManager);
  22. // Parse the XNB data.
  23. int exitCode = 0;
  24. try
  25. {
  26. reader.ReadXnb();
  27. }
  28. catch (exception& e)
  29. {
  30. printf("Error: %s\n", e.what());
  31. exitCode = 1;
  32. }
  33. fclose(file);
  34. return exitCode;
  35. }