Mercurial > octave-nkf
diff src/sysdep.cc @ 6691:c6ee6c342699
[project @ 2007-06-05 05:50:10 by jwe]
author | jwe |
---|---|
date | Tue, 05 Jun 2007 05:50:10 +0000 |
parents | 9a8861bc2b34 |
children | 6b7ba4a31876 |
line wrap: on
line diff
--- a/src/sysdep.cc Mon Jun 04 22:44:32 2007 +0000 +++ b/src/sysdep.cc Tue Jun 05 05:50:10 2007 +0000 @@ -232,47 +232,38 @@ { #ifdef OCTAVE_USE_WINDOWS_API + bool retval = false; + // Windows native code // Reference: http://msdn2.microsoft.com/en-us/library/aa363788.aspx - HANDLE hfile1; - HANDLE hfile2; - - BY_HANDLE_FILE_INFORMATION hfi1; - BY_HANDLE_FILE_INFORMATION hfi2; - - hfile1 = CreateFile (file1.c_str (), 0, FILE_SHARE_READ, 0, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); + HANDLE hfile1 = CreateFile (file1.c_str (), 0, FILE_SHARE_READ, 0, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); + + if (hfile1 != INVALID_HANDLE_VALUE) + { + HANDLE hfile2 = CreateFile (file2.c_str (), 0, FILE_SHARE_READ, 0, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); - if (hfile1 == INVALID_HANDLE_VALUE) - return false; + if (hfile2 != INVALID_HANDLE_VALUE) + { + BY_HANDLE_FILE_INFORMATION hfi1; + BY_HANDLE_FILE_INFORMATION hfi2; + + if (GetFileInformationByHandle (hfile1, &hfi1) + && GetFileInformationByHandle (hfile2, &hfi2)) - hfile2 = CreateFile (file2.c_str (), 0, FILE_SHARE_READ, 0, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); + retval = (hfi1.dwVolumeSerialNumber == hfi2.dwVolumeSerialNumber + && hfi1.nFileIndexHigh == hfi2.nFileIndexHigh + && hfi1.nFileIndexLow == hfi2.nFileIndexLow); - if (hfile2 == INVALID_HANDLE_VALUE) - { + CloseHandle (hfile2); + } + CloseHandle (hfile1); - return false; } - - if (! GetFileInformationByHandle (hfile1, &hfi1)) - { - CloseHandle (hfile1); - CloseHandle (hfile2); - return false; - } - - if (! GetFileInformationByHandle (hfile2, &hfi2)) - { - CloseHandle (hfile1); - CloseHandle (hfile2); - return false; - } - - return (hfi1.dwVolumeSerialNumber == hfi2.dwVolumeSerialNumber - && hfi1.nFileIndexHigh == hfi2.nFileIndexHigh - && hfi1.nFileIndexLow == hfi2.nFileIndexLow); + + return retval; #else