Module: Winhelper
- Extended by:
- FFI::Library
- Defined in:
- lib/filewatch/winhelper.rb
Defined Under Namespace
Classes: FileInformation, FileTime
Class Method Summary collapse
Class Method Details
.GetWindowsUniqueFileIdentifier(path) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/filewatch/winhelper.rb', line 47 def self.GetWindowsUniqueFileIdentifier(path) handle = GetOpenFileHandle(path, 0, 7, nil, 3, 128, nil) fileInfo = Winhelper::FileInformation.new success = GetFileInformationByHandle(handle, fileInfo) CloseHandle(handle) if success == 1 #args = [ # fileInfo[:fileAttributes], fileInfo[:volumeSerialNumber], fileInfo[:fileSizeHigh], fileInfo[:fileSizeLow], # fileInfo[:numberOfLinks], fileInfo[:fileIndexHigh], fileInfo[:fileIndexLow] # ] #p "Information: %u %u %u %u %u %u %u " % args #this is only guaranteed on NTFS, for ReFS on windows 2012, GetFileInformationByHandleEx should be used with FILE_ID_INFO, which returns a 128 bit identifier return "#{fileInfo[:volumeSerialNumber]}-#{fileInfo[:fileIndexLow]}-#{fileInfo[:fileIndexHigh]}" else #p "cannot retrieve file information, returning path" return path; end end |