// Reads file data into the buffer.
// Returns true on success.
// Max file size <= min(max int, max vector::size_type)
BASE_EXPORT bool ReadFile(const FilePath& filename, std::vector<char>* data);
bool ReadFile(const FilePath& filename, std::vector<char>* data) {
DCHECK(data);
int64 file_size_64 = 0;
if (GetFileSize(filename, &file_size_64)) {
const int file_size = checked_cast<int>(file_size_64);
if (file_size > 0) {
data->resize(checked_cast<size_t>(file_size));
if (file_size == ReadFile(filename, data->data(), file_size)) {
return true;
}
}
}
return false;
}