| 189 | } |
| 190 | |
| 191 | bool Explorer::IsFileBinary(const std::string &path) { |
| 192 | const auto full_path = this->MakeFull(path); |
| 193 | if(!this->IsFile(full_path)) { |
| 194 | return false; |
| 195 | } |
| 196 | const auto file_size = this->GetFileSize(full_path); |
| 197 | if(file_size == 0) { |
| 198 | return true; |
| 199 | } |
| 200 | |
| 201 | const auto to_read_size = std::min(file_size, BinaryCheckWorkBufferSize); |
| 202 | const auto read_size = this->ReadFile(full_path, 0, to_read_size, g_BinaryCheckWorkBuffer); |
| 203 | if(read_size == 0) { |
| 204 | return true; |
| 205 | } |
| 206 | else { |
| 207 | for(u32 i = 0; i < read_size; i++) { |
| 208 | const auto cur_ch = static_cast<char>(g_BinaryCheckWorkBuffer[i]); |
| 209 | if(!IsCharacterText(cur_ch)) { |
| 210 | return true; |
| 211 | } |
| 212 | } |
| 213 | return false; |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | std::vector<u8> Explorer::ReadFile(const std::string &path) { |
| 218 | const auto full_path = this->MakeFull(path); |
no test coverage detected