Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ChakraCore.h"
- #include<stdlib.h>
- #include <string>
- #include <iostream>
- #include <chrono>
- #include<string.h>
- #include<stdio.h>
- using namespace std::chrono;
- using namespace std;
- void LoadBinaryFile(FILE * file,char* & contents, unsigned int & lengthBytes)
- {
- contents = nullptr;
- lengthBytes = 0;
- size_t result;
- //
- // Determine the file length, in bytes.
- //
- fseek(file, 0, SEEK_END);
- lengthBytes = ftell(file);
- fseek(file, 0, SEEK_SET);
- contents = (char*)malloc(lengthBytes);
- if (nullptr == contents)
- {
- return ;
- }
- //
- // Read the entire content as a binary block.
- //
- result = fread((void*)contents, sizeof(char), lengthBytes, file);
- if (result != lengthBytes)
- {
- free(contents);
- contents=nullptr;
- return ;
- }
- return ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement