filewatch 0.6.5 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/filewatch/winhelper.rb +57 -63
- metadata +25 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5838846b40579f933b08efa2679143c4d6c3a653
|
4
|
+
data.tar.gz: a0e819627f6fdb49a4aaceeac7e8393596772205
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27da5e65f6aeb55e0cb1b2633c9dc2e8eac7d585d16c9efbc2002e1e01df2260a502d8586783d73beefc9b2dc6a8f70945101592c78eafa221e62e20328b1d14
|
7
|
+
data.tar.gz: 916bfe75bc6b4f1805159ca004497c5a3ca68960f953b2f607fc9469aca77c525e04654c64bd39b612b63b42b684e99722a29277af28e27f2aa48bd9380048c4
|
data/lib/filewatch/winhelper.rb
CHANGED
@@ -1,70 +1,64 @@
|
|
1
1
|
require "ffi"
|
2
|
-
|
2
|
+
|
3
3
|
module Winhelper
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
fileInfo
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
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.
|
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-
|
13
|
-
dependencies:
|
14
|
-
|
15
|
-
|
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.
|
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: []
|