This appears to work :
bool IsSameFile(char * Name1,char * Name2) { HANDLE f1,f2; BY_HANDLE_FILE_INFORMATION info1; BY_HANDLE_FILE_INFORMATION info2; f1 = CreateFile(Name1,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,0,0); if ( f1 == INVALID_HANDLE_VALUE ) return false; f2 = CreateFile(Name2,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,0,0); if ( f2 == INVALID_HANDLE_VALUE ) { CloseHandle(f1); return false; } GetFileInformationByHandle(f1,&info1); GetFileInformationByHandle(f2,&info2); CloseHandle(f1); CloseHandle(f2); // BY_HANDLE_FILE_INFORMATION has a unique file ID and Volume Serial Number in it // check those are the same // heh fuck it just check they are all the same // confirmed : this does work across substs return memcmp(&info1,&info2,sizeof(info1)) == 0; }
No comments:
Post a Comment