134 try { wide_path = string_tools::utf8_to_utf16(path_to_file); }
catch (...) {
return false; }
135 HANDLE file_handle = CreateFileW(wide_path.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
136 if (file_handle == INVALID_HANDLE_VALUE)
139 if ((file_size == INVALID_FILE_SIZE) || (
uint64_t)file_size > (
uint64_t)max_size) {
140 CloseHandle(file_handle);
143 target_str.resize(file_size);
145 BOOL result = ReadFile(file_handle, &target_str[0], file_size, &bytes_read, NULL);
146 CloseHandle(file_handle);
147 if (bytes_read != file_size)
153 std::ifstream fstream;
154 fstream.exceptions(std::ifstream::failbit | std::ifstream::badbit);
155 fstream.open(path_to_file, std::ios_base::binary | std::ios_base::in | std::ios::ate);
157 std::ifstream::pos_type file_size = fstream.tellg();
161 size_t file_size_t =
static_cast<size_t>(file_size);
163 target_str.resize(file_size_t);
165 fstream.seekg (0, std::ios::beg);
166 fstream.read((
char*)target_str.data(), target_str.size());
GTEST_API_ size_t GetFileSize(FILE *file)
unsigned __int64 uint64_t