| 180 | } |
| 181 | |
| 182 | bool HasMultipleLinksUtf8(const std::string& fileName) { |
| 183 | #ifdef _WIN32 |
| 184 | const std::wstring wideFileName = internal::WideFromUtf8(fileName); |
| 185 | HANDLE handle = |
| 186 | CreateFileW(wideFileName.c_str(), 0, |
| 187 | FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, |
| 188 | nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); |
| 189 | if (handle == INVALID_HANDLE_VALUE) { |
| 190 | return false; |
| 191 | } |
| 192 | BY_HANDLE_FILE_INFORMATION fileInfo; |
| 193 | const bool success = GetFileInformationByHandle(handle, &fileInfo) != 0; |
| 194 | CloseHandle(handle); |
| 195 | return success && fileInfo.nNumberOfLinks > 1; |
| 196 | #else |
| 197 | struct stat fileStat; |
| 198 | if (stat(fileName.c_str(), &fileStat) != 0) { |
| 199 | return false; |
| 200 | } |
| 201 | return fileStat.st_nlink > 1; |
| 202 | #endif |
| 203 | } |
| 204 | |
| 205 | bool IsSameFileUtf8(const std::string& first, const std::string& second) { |
| 206 | #ifdef _WIN32 |
no test coverage detected