diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2002-04-19 12:27:50 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2002-04-19 12:27:50 (GMT) |
commit | 75f9434374ec2ed5e0f516ff914e9c2b4c519e33 (patch) | |
tree | 44e0f7b93c01403e92717365921fc350aa6776ee /Source/cmSystemTools.cxx | |
parent | dd7ab1f577b05a15fadc96d4705a4006e42fb51c (diff) | |
download | CMake-75f9434374ec2ed5e0f516ff914e9c2b4c519e33.zip CMake-75f9434374ec2ed5e0f516ff914e9c2b4c519e33.tar.gz CMake-75f9434374ec2ed5e0f516ff914e9c2b4c519e33.tar.bz2 |
BUG: fix SameFile function for windows, and compare source directories
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r-- | Source/cmSystemTools.cxx | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 1f68b70..5accbaa 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -487,6 +487,47 @@ std::string cmSystemTools::EscapeQuotes(const char* str) bool cmSystemTools::SameFile(const char* file1, const char* file2) { +#ifdef _WIN32 + HANDLE hFile1, hFile2; + + hFile1 = CreateFile( file1, + GENERIC_READ, + FILE_SHARE_READ , + NULL, + OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS, + NULL + ); + hFile2 = CreateFile( file2, + GENERIC_READ, + FILE_SHARE_READ, + NULL, + OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS, + NULL + ); + if( hFile1 == INVALID_HANDLE_VALUE || hFile2 == INVALID_HANDLE_VALUE) + { + if(hFile1 != INVALID_HANDLE_VALUE) + { + CloseHandle(hFile1); + } + if(hFile2 != INVALID_HANDLE_VALUE) + { + CloseHandle(hFile2); + } + return false; + } + + BY_HANDLE_FILE_INFORMATION fiBuf1; + BY_HANDLE_FILE_INFORMATION fiBuf2; + GetFileInformationByHandle( hFile1, &fiBuf1 ); + GetFileInformationByHandle( hFile2, &fiBuf2 ); + CloseHandle(hFile1); + CloseHandle(hFile2); + return (fiBuf1.nFileIndexHigh == fiBuf2.nFileIndexHigh && + fiBuf1.nFileIndexLow == fiBuf2.nFileIndexLow); +#else struct stat fileStat1, fileStat2; if (stat(file1, &fileStat1) == 0 && stat(file2, &fileStat2) == 0) { @@ -501,6 +542,7 @@ bool cmSystemTools::SameFile(const char* file1, const char* file2) } } return false; +#endif } |