That's the default hash method implementation to compute a hash key based on a file content.
| 331 | |
| 332 | // That's the default hash method implementation to compute a hash key based on a file content. |
| 333 | std::string CreateFileContentHash(const std::string &filename) |
| 334 | { |
| 335 | #if defined(_WIN32) && defined(UNICODE) |
| 336 | struct _stat fileInfo; |
| 337 | if (_wstat(Platform::Utf8ToUtf16(filename).c_str(), &fileInfo) == 0) |
| 338 | #else |
| 339 | struct stat fileInfo; |
| 340 | if (stat(filename.c_str(), &fileInfo) == 0) |
| 341 | #endif |
| 342 | { |
| 343 | // Treat the st_dev (i.e. device) + st_ino (i.e. inode) as a proxy for the contents. |
| 344 | |
| 345 | std::ostringstream fasthash; |
| 346 | fasthash << fileInfo.st_dev << ":"; |
| 347 | #ifdef _WIN32 |
| 348 | // TODO: The hard-linked files are then not correctly supported on Windows platforms. |
| 349 | fasthash << std::hash<std::string>{}(filename); |
| 350 | #else |
| 351 | fasthash << fileInfo.st_ino; |
| 352 | #endif |
| 353 | return fasthash.str(); |
| 354 | } |
| 355 | |
| 356 | return ""; |
| 357 | } |
| 358 | |
| 359 | } // Platform |
| 360 |
nothing calls this directly
no test coverage detected