Created
March 4, 2015 22:13
-
-
Save yhirose/caea7b4a8d437acb2731 to your computer and use it in GitHub Desktop.
read_file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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