| 1310 | #endif |
| 1311 | |
| 1312 | bool SystemTools::GetFileId(std::string const& file, FileId& id) |
| 1313 | { |
| 1314 | #ifdef _WIN32 |
| 1315 | HANDLE hFile = |
| 1316 | CreateFileW(Encoding::ToWide(file).c_str(), GENERIC_READ, FILE_SHARE_READ, |
| 1317 | nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr); |
| 1318 | if (hFile != INVALID_HANDLE_VALUE) { |
| 1319 | BY_HANDLE_FILE_INFORMATION fiBuf; |
| 1320 | GetFileInformationByHandle(hFile, &fiBuf); |
| 1321 | CloseHandle(hFile); |
| 1322 | id = FileId(fiBuf.dwVolumeSerialNumber, fiBuf.nFileIndexHigh, |
| 1323 | fiBuf.nFileIndexLow); |
| 1324 | return true; |
| 1325 | } else { |
| 1326 | return false; |
| 1327 | } |
| 1328 | #else |
| 1329 | struct stat fileStat; |
| 1330 | if (stat(file.c_str(), &fileStat) == 0) { |
| 1331 | id = FileId(fileStat.st_dev, fileStat.st_ino, fileStat.st_size); |
| 1332 | return true; |
| 1333 | } |
| 1334 | return false; |
| 1335 | #endif |
| 1336 | } |
| 1337 | |
| 1338 | bool SystemTools::SameFile(std::string const& file1, std::string const& file2) |
| 1339 | { |