FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

GitHub Viewer

#include "Utils.h" // Check if a file exists bool Utils::FileExists(string p_sPath) { if (FILE * file = fopen(p_sPath.c_str(), "r")) { fclose(file); return true; } else { return false; } } // Delete a file bool Utils::DeleteSourceFile(string p_sFile) { return (bool)remove(p_sFile.c_str()); } // Function used to read a file string Utils::ReadSourceFile(string p_sFilename) { string contents = ""; FILE* f = fopen(p_sFilename.c_str(), "rb"); // Get file size fseek(f, 0, SEEK_END); size_t size = ftell(f); char* cdata = new char[size + 1]; cdata[size] = '\0'; // Read file rewind(f); fread(cdata, sizeof(char), size, f); fclose(f); // Return data contents = cdata; delete[] cdata; return contents; } // Get the size of a file size_t Utils::GetSize(string p_sFilename) { size_t size; FILE* f = fopen(p_sFilename.c_str(), "rb"); // Get file size fseek(f, 0, SEEK_END); size = ftell(f); rewind(f); fclose(f); return size; } // Read binary file unsigned char* Utils::ReadBinaryFile(string p_sFilename, size_t *p_rSize) { unsigned char *p = NULL; FILE* f = NULL; size_t res = 0; if (!FileExists(p_sFilename)) { cout

Back | FazBrowse Home | New Git URL