MCPcopy Create free account
hub / github.com/Kitware/CMake / GetFileId

Method GetFileId

Source/kwsys/SystemTools.cxx:1312–1336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1310#endif
1311
1312bool 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
1338bool SystemTools::SameFile(std::string const& file1, std::string const& file2)
1339{

Callers

nothing calls this directly

Calls 2

c_strMethod · 0.80
statClass · 0.70

Tested by

no test coverage detected