Skip to content

Instantly share code, notes, and snippets.

@yhirose
Created March 4, 2015 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yhirose/caea7b4a8d437acb2731 to your computer and use it in GitHub Desktop.
Save yhirose/caea7b4a8d437acb2731 to your computer and use it in GitHub Desktop.
read_file
bool read_file(const char* path, vector<char>& buff)
{
ifstream ifs(path, ios::in | ios::binary);
if (ifs.fail()) {
return false;
}
buff.resize(static_cast<unsigned int>(ifs.seekg(0, ios::end).tellg()));
if (!buff.empty()) {
ifs.seekg(0, ios::beg).read(&buff[0], static_cast<streamsize>(buff.size()));
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment