Advertisement
Guest User

Untitled

a guest
May 23rd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #include "ChakraCore.h"
  2. #include<stdlib.h>
  3. #include <string>
  4. #include <iostream>
  5. #include <chrono>
  6. #include<string.h>
  7. #include<stdio.h>
  8. using namespace std::chrono;
  9.  
  10. using namespace std;
  11. void LoadBinaryFile(FILE * file,char* & contents, unsigned int & lengthBytes)
  12. {
  13. contents = nullptr;
  14. lengthBytes = 0;
  15. size_t result;
  16.  
  17. //
  18. // Determine the file length, in bytes.
  19. //
  20. fseek(file, 0, SEEK_END);
  21. lengthBytes = ftell(file);
  22. fseek(file, 0, SEEK_SET);
  23. contents = (char*)malloc(lengthBytes);
  24. if (nullptr == contents)
  25. {
  26. return ;
  27. }
  28. //
  29. // Read the entire content as a binary block.
  30. //
  31. result = fread((void*)contents, sizeof(char), lengthBytes, file);
  32. if (result != lengthBytes)
  33. {
  34. free(contents);
  35. contents=nullptr;
  36. return ;
  37. }
  38.  
  39. return ;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement