filewatch 0.6.5 → 0.6.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/filewatch/winhelper.rb +57 -63
  3. metadata +25 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cde10a47b03d07ac8e98d55149578c26e142e99c
4
- data.tar.gz: cef7339b77f49c9ac4becf66ebd7d8a2cf6eb4bb
3
+ metadata.gz: 5838846b40579f933b08efa2679143c4d6c3a653
4
+ data.tar.gz: a0e819627f6fdb49a4aaceeac7e8393596772205
5
5
  SHA512:
6
- metadata.gz: 909fad240a5d70a6b722f529151d910f256acd568b3f19d242ba82421257a269b9c8eecffea1f74af723f77fe1a4b6660d15544e3fc278ec1ef6d83da1172105
7
- data.tar.gz: 11f35e0301f76a1fcc5d75cf55f1b4c59832ebd5bf0117a8bbedf1594866b8e2b817a4005e5e739837bb4634a8fc107d0abcc6de64de1b89848b3076268d3923
6
+ metadata.gz: 27da5e65f6aeb55e0cb1b2633c9dc2e8eac7d585d16c9efbc2002e1e01df2260a502d8586783d73beefc9b2dc6a8f70945101592c78eafa221e62e20328b1d14
7
+ data.tar.gz: 916bfe75bc6b4f1805159ca004497c5a3ca68960f953b2f607fc9469aca77c525e04654c64bd39b612b63b42b684e99722a29277af28e27f2aa48bd9380048c4
@@ -1,70 +1,64 @@
1
1
  require "ffi"
2
-
2
+
3
3
  module Winhelper
4
- extend FFI::Library
5
-
6
- ffi_lib 'kernel32'
7
- ffi_convention :stdcall
8
- class FileTime < FFI::Struct
9
- layout :lowDateTime, :uint,
10
- :highDateTime, :uint
11
- end
12
-
13
- #http://msdn.microsoft.com/en-us/library/windows/desktop/aa363788(v=vs.85).aspx
14
- class FileInformation < FFI::Struct
15
- def initialize()
16
- createTime = FileTime.new
17
- lastAccessTime = FileTime.new
18
- lastWriteTime = FileTime.new
19
- end
20
-
21
- layout :fileAttributes, :uint, #DWORD dwFileAttributes;
22
- :createTime, FileTime, #FILETIME ftCreationTime;
23
- :lastAccessTime, FileTime, #FILETIME ftLastAccessTime;
24
- :lastWriteTime, FileTime, #FILETIME ftLastWriteTime;
25
- :volumeSerialNumber, :uint, #DWORD dwVolumeSerialNumber;
26
- :fileSizeHigh, :uint, #DWORD nFileSizeHigh;
27
- :fileSizeLow, :uint, #DWORD nFileSizeLow;
28
- :numberOfLinks, :uint, #DWORD nNumberOfLinks;
29
- :fileIndexHigh, :uint, #DWORD nFileIndexHigh;
30
- :fileIndexLow, :uint #DWORD nFileIndexLow;
31
- end
32
-
33
-
34
- #http://msdn.microsoft.com/en-us/library/windows/desktop/aa363858(v=vs.85).aspx
35
- #HANDLE WINAPI CreateFile(_In_ LPCTSTR lpFileName,_In_ DWORD dwDesiredAccess,_In_ DWORD dwShareMode,
36
- # _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes,_In_ DWORD dwCreationDisposition,
37
- # _In_ DWORD dwFlagsAndAttributes,_In_opt_ HANDLE hTemplateFile);
38
- attach_function :GetOpenFileHandle, :CreateFileA, [:pointer, :uint, :uint, :pointer, :uint, :uint, :pointer], :pointer
39
-
40
- #http://msdn.microsoft.com/en-us/library/windows/desktop/aa364952(v=vs.85).aspx
41
- #BOOL WINAPI GetFileInformationByHandle(_In_ HANDLE hFile,_Out_ LPBY_HANDLE_FILE_INFORMATION lpFileInformation);
42
- attach_function :GetFileInformationByHandle, [:pointer, :pointer], :int
43
-
44
- attach_function :CloseHandle, [:pointer], :int
45
-
46
-
47
- def self.GetWindowsUniqueFileIdentifier(path)
48
- handle = GetOpenFileHandle(path, 0, 7, nil, 3, 128, nil)
49
- fileInfo = Winhelper::FileInformation.new
50
- success = GetFileInformationByHandle(handle, fileInfo)
51
- CloseHandle(handle)
52
- if success == 1
53
- #args = [
54
- # fileInfo[:fileAttributes], fileInfo[:volumeSerialNumber], fileInfo[:fileSizeHigh], fileInfo[:fileSizeLow],
55
- # fileInfo[:numberOfLinks], fileInfo[:fileIndexHigh], fileInfo[:fileIndexLow]
56
- # ]
57
- #p "Information: %u %u %u %u %u %u %u " % args
58
- #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
59
- return "#{fileInfo[:volumeSerialNumber]}-#{fileInfo[:fileIndexLow]}-#{fileInfo[:fileIndexHigh]}"
60
- else
61
- #p "cannot retrieve file information, returning path"
62
- return path;
63
- end
64
- end
4
+ extend FFI::Library
5
+
6
+ ffi_lib 'kernel32'
7
+ ffi_convention :stdcall
8
+ class FileTime < FFI::Struct
9
+ layout :lowDateTime, :uint,
10
+ :highDateTime, :uint
11
+ end
12
+
13
+ #http://msdn.microsoft.com/en-us/library/windows/desktop/aa363788(v=vs.85).aspx
14
+ class FileInformation < FFI::Struct
15
+ layout :fileAttributes, :uint, #DWORD dwFileAttributes;
16
+ :createTime, FileTime, #FILETIME ftCreationTime;
17
+ :lastAccessTime, FileTime, #FILETIME ftLastAccessTime;
18
+ :lastWriteTime, FileTime, #FILETIME ftLastWriteTime;
19
+ :volumeSerialNumber, :uint, #DWORD dwVolumeSerialNumber;
20
+ :fileSizeHigh, :uint, #DWORD nFileSizeHigh;
21
+ :fileSizeLow, :uint, #DWORD nFileSizeLow;
22
+ :numberOfLinks, :uint, #DWORD nNumberOfLinks;
23
+ :fileIndexHigh, :uint, #DWORD nFileIndexHigh;
24
+ :fileIndexLow, :uint #DWORD nFileIndexLow;
25
+ end
26
+
27
+
28
+ #http://msdn.microsoft.com/en-us/library/windows/desktop/aa363858(v=vs.85).aspx
29
+ #HANDLE WINAPI CreateFile(_In_ LPCTSTR lpFileName,_In_ DWORD dwDesiredAccess,_In_ DWORD dwShareMode,
30
+ # _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes,_In_ DWORD dwCreationDisposition,
31
+ # _In_ DWORD dwFlagsAndAttributes,_In_opt_ HANDLE hTemplateFile);
32
+ attach_function :GetOpenFileHandle, :CreateFileA, [:pointer, :uint, :uint, :pointer, :uint, :uint, :pointer], :pointer
33
+
34
+ #http://msdn.microsoft.com/en-us/library/windows/desktop/aa364952(v=vs.85).aspx
35
+ #BOOL WINAPI GetFileInformationByHandle(_In_ HANDLE hFile,_Out_ LPBY_HANDLE_FILE_INFORMATION lpFileInformation);
36
+ attach_function :GetFileInformationByHandle, [:pointer, :pointer], :int
37
+
38
+ attach_function :CloseHandle, [:pointer], :int
39
+
40
+
41
+ def self.GetWindowsUniqueFileIdentifier(path)
42
+ handle = GetOpenFileHandle(path, 0, 7, nil, 3, 128, nil)
43
+ fileInfo = Winhelper::FileInformation.new
44
+ success = GetFileInformationByHandle(handle, fileInfo)
45
+ CloseHandle(handle)
46
+ if success == 1
47
+ #args = [
48
+ # fileInfo[:fileAttributes], fileInfo[:volumeSerialNumber], fileInfo[:fileSizeHigh], fileInfo[:fileSizeLow],
49
+ # fileInfo[:numberOfLinks], fileInfo[:fileIndexHigh], fileInfo[:fileIndexLow]
50
+ # ]
51
+ #p "Information: %u %u %u %u %u %u %u " % args
52
+ #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
53
+ return "#{fileInfo[:volumeSerialNumber]}-#{fileInfo[:fileIndexLow]}-#{fileInfo[:fileIndexHigh]}"
54
+ else
55
+ #p "cannot retrieve file information, returning path"
56
+ return path;
57
+ end
58
+ end
65
59
  end
66
60
 
67
61
  #fileId = Winhelper.GetWindowsUniqueFileIdentifier('C:\inetpub\logs\LogFiles\W3SVC1\u_ex1fdsadfsadfasdf30612.log')
68
62
  #p "FileId: " + fileId
69
63
  #p "outside function, sleeping"
70
- #sleep(10)
64
+ #sleep(10)
metadata CHANGED
@@ -1,18 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filewatch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5
4
+ version: 0.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordan Sissel
8
8
  - Pete Fritchman
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-08-11 00:00:00.000000000 Z
13
- dependencies: []
14
- description: Watch files and directories in ruby. Also supports tailing and glob file
15
- patterns.
12
+ date: 2015-10-28 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ name: stud
21
+ prerelease: false
22
+ type: :development
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - '>='
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ description: Watch files and directories in ruby. Also supports tailing and glob file patterns.
16
29
  email:
17
30
  - jls@semicomplete.com
18
31
  - petef@databits.net
@@ -54,25 +67,25 @@ files:
54
67
  homepage: https://github.com/jordansissel/ruby-filewatch
55
68
  licenses: []
56
69
  metadata: {}
57
- post_install_message:
70
+ post_install_message:
58
71
  rdoc_options: []
59
72
  require_paths:
60
73
  - lib
61
74
  - lib
62
75
  required_ruby_version: !ruby/object:Gem::Requirement
63
76
  requirements:
64
- - - ">="
77
+ - - '>='
65
78
  - !ruby/object:Gem::Version
66
79
  version: '0'
67
80
  required_rubygems_version: !ruby/object:Gem::Requirement
68
81
  requirements:
69
- - - ">="
82
+ - - '>='
70
83
  - !ruby/object:Gem::Version
71
84
  version: '0'
72
85
  requirements: []
73
- rubyforge_project:
74
- rubygems_version: 2.4.6
75
- signing_key:
86
+ rubyforge_project:
87
+ rubygems_version: 2.4.8
88
+ signing_key:
76
89
  specification_version: 4
77
90
  summary: filewatch - file watching for ruby
78
91
  test_files: []