Method: Winhelper.identifier_from_handle
- Defined in:
- lib/filewatch/winhelper.rb
.identifier_from_handle(handle, close_handle = true) ⇒ Object
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/filewatch/winhelper.rb', line 159 def self.identifier_from_handle(handle, close_handle = true) fileInfo = Winhelper::FileInformation.new success = GetFileInformationByHandle(handle, fileInfo) if success > 0 #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 return 'unknown' end ensure CloseHandle(handle) if close_handle end |