win32-changenotify 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +10 -0
- data/MANIFEST +1 -2
- data/README +3 -6
- data/Rakefile +4 -2
- data/examples/example_win32_changenotify.rb +35 -0
- data/lib/win32/changenotify.rb +56 -44
- data/test/{tc_changenotify.rb → test_win32_changenotify.rb} +3 -3
- data/win32-changenotify.gemspec +16 -12
- metadata +57 -53
data/CHANGES
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
== 0.5.1 - 21-Aug-2009
|
2
|
+
* License changed to Artistic 2.0.
|
3
|
+
* The ChangeNotify#wait method is now slightly more robust.
|
4
|
+
* Renamed test file to test_win32_changenotify.rb.
|
5
|
+
* Some gemspec updates, including license and description.
|
6
|
+
* Renamed example file to example_win32_changenotify.rb to avoid any
|
7
|
+
confusion with actual test files.
|
8
|
+
* Removed the doc/changenotify.txt file because I felt it was redundant.
|
9
|
+
* Added an example rake task.
|
10
|
+
|
1
11
|
== 0.5.0 - 9-Aug-2007
|
2
12
|
* Now pure Ruby!
|
3
13
|
* Now requires the win32-event library.
|
data/MANIFEST
CHANGED
@@ -3,10 +3,9 @@
|
|
3
3
|
* MANIFEST
|
4
4
|
* Rakefile
|
5
5
|
* win32-changenotify.gemspec
|
6
|
-
* doc/changenotify.txt
|
7
6
|
* examples/test.rb
|
8
7
|
* ext/extconf.rb
|
9
8
|
* ext/win32/changenotify.c
|
10
9
|
* ext/win32/changenotify.h
|
11
10
|
* lib/win32/changenotify.rb
|
12
|
-
* test/
|
11
|
+
* test/test_win32_changenotify.rb
|
data/README
CHANGED
@@ -47,9 +47,6 @@
|
|
47
47
|
This library is deprecated in favor of win32-changejournal on NTFS
|
48
48
|
filesystems.
|
49
49
|
|
50
|
-
For additional documentation please see the 'changenotify.txt' file under
|
51
|
-
the 'doc' directory.
|
52
|
-
|
53
50
|
= Pure Ruby vs C Extension
|
54
51
|
The C code we used for this library prior to 0.5.0 is still available in
|
55
52
|
CVS for this project, but is not distributed with official releases. Note
|
@@ -74,7 +71,7 @@
|
|
74
71
|
|
75
72
|
= Future Plans
|
76
73
|
Probably none. This library is deprecated in favor of win32-changejournal.
|
77
|
-
However, that library only works on NTFS filesystems, so this
|
74
|
+
However, that library only works on NTFS filesystems, so this library will
|
78
75
|
be maintained as well.
|
79
76
|
|
80
77
|
That being said, I'm always open to improvements, so feel free to submit
|
@@ -85,10 +82,10 @@
|
|
85
82
|
project page at http://www.rubyforge.net/projects/win32utils
|
86
83
|
|
87
84
|
= License
|
88
|
-
|
85
|
+
Artistic 2.0
|
89
86
|
|
90
87
|
= Copyright
|
91
|
-
(C) 2003-
|
88
|
+
(C) 2003-2009 Daniel J. Berger, All Rights Reserved
|
92
89
|
|
93
90
|
= Warranty
|
94
91
|
This package is provided "as is" and without any express or
|
data/Rakefile
CHANGED
@@ -20,9 +20,11 @@ task :install_gem do
|
|
20
20
|
sh "gem install #{file}"
|
21
21
|
end
|
22
22
|
|
23
|
+
desc 'Run the example program'
|
24
|
+
task :example do
|
25
|
+
ruby '-Ilib examples/example_win32_changenotify.rb'
|
26
|
+
|
23
27
|
Rake::TestTask.new do |t|
|
24
|
-
t.libs << 'test'
|
25
28
|
t.verbose = true
|
26
29
|
t.warning = true
|
27
|
-
t.test_files = FileList['test/tc_changenotify.rb']
|
28
30
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#######################################################################
|
2
|
+
# example_win32_changenotify.rb
|
3
|
+
#
|
4
|
+
# An example script for general futzing and demonstration. You can
|
5
|
+
# run this program via the 'rake example' task.
|
6
|
+
#
|
7
|
+
# Modify as you see fit.
|
8
|
+
#######################################################################
|
9
|
+
require 'win32/changenotify'
|
10
|
+
require 'pp'
|
11
|
+
include Win32
|
12
|
+
|
13
|
+
puts "VERSION: " + ChangeNotify::VERSION
|
14
|
+
|
15
|
+
puts "This will run for 20 seconds"
|
16
|
+
|
17
|
+
flags = ChangeNotify::FILE_NAME | ChangeNotify::DIR_NAME
|
18
|
+
flags |= ChangeNotify::LAST_WRITE
|
19
|
+
|
20
|
+
cn = ChangeNotify.new("c:\\", true, flags)
|
21
|
+
|
22
|
+
# Wait up to 20 seconds for something to happen
|
23
|
+
begin
|
24
|
+
cn.wait(20){ |events|
|
25
|
+
events.each { |event|
|
26
|
+
puts "Something changed"
|
27
|
+
puts "File: " + event.file_name
|
28
|
+
puts "Action: " + event.action
|
29
|
+
}
|
30
|
+
}
|
31
|
+
rescue
|
32
|
+
cn.close
|
33
|
+
end
|
34
|
+
|
35
|
+
puts "ChangeNotify example program done"
|
data/lib/win32/changenotify.rb
CHANGED
@@ -5,7 +5,10 @@ require 'windows/directory'
|
|
5
5
|
require 'windows/unicode'
|
6
6
|
require 'windows/msvcrt/buffer'
|
7
7
|
|
8
|
+
# The Win32 module serves as a namespace only
|
8
9
|
module Win32
|
10
|
+
|
11
|
+
# The Win32::ChangeNotify class encapsulates filesystem change notifications
|
9
12
|
class ChangeNotify < Ipc
|
10
13
|
include Windows::NIO
|
11
14
|
include Windows::File
|
@@ -13,8 +16,8 @@ module Win32
|
|
13
16
|
include Windows::Unicode
|
14
17
|
include Windows::MSVCRT::Buffer
|
15
18
|
|
16
|
-
# The version of
|
17
|
-
VERSION = '0.5.
|
19
|
+
# The version of the win32-changenotify library
|
20
|
+
VERSION = '0.5.1'
|
18
21
|
|
19
22
|
# Aliased constants
|
20
23
|
|
@@ -36,6 +39,8 @@ module Win32
|
|
36
39
|
# Filter: File size changes
|
37
40
|
SIZE = FILE_NOTIFY_CHANGE_SIZE
|
38
41
|
|
42
|
+
# :stopdoc:
|
43
|
+
|
39
44
|
# Private constants
|
40
45
|
|
41
46
|
# File was added
|
@@ -56,6 +61,8 @@ module Win32
|
|
56
61
|
# Yielded by the ChangeNotify#wait method
|
57
62
|
ChangeNotifyStruct = Struct.new('ChangeNotifyStruct', :action, :file_name)
|
58
63
|
|
64
|
+
# :startdoc:
|
65
|
+
|
59
66
|
# The path that was provided to the constructor
|
60
67
|
attr_reader :path
|
61
68
|
|
@@ -137,48 +144,14 @@ module Win32
|
|
137
144
|
subtree = @recursive ? 1 : 0
|
138
145
|
dir_handle = get_dir_handle(@path)
|
139
146
|
comp_key = [12345].pack('L')
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
if comp_port == 0
|
144
|
-
raise Error, get_last_error
|
145
|
-
end
|
146
|
-
|
147
|
-
bool = ReadDirectoryChangesW(
|
148
|
-
dir_handle,
|
149
|
-
fni,
|
150
|
-
fni.size,
|
151
|
-
subtree,
|
152
|
-
@filter,
|
153
|
-
rbytes,
|
154
|
-
@overlap,
|
155
|
-
0
|
156
|
-
)
|
157
|
-
|
158
|
-
unless bool
|
159
|
-
raise Error, get_last_error
|
160
|
-
end
|
161
|
-
|
162
|
-
while true
|
163
|
-
bool = GetQueuedCompletionStatus(
|
164
|
-
comp_port,
|
165
|
-
qbytes,
|
166
|
-
comp_key,
|
167
|
-
@overlap,
|
168
|
-
seconds
|
169
|
-
)
|
147
|
+
|
148
|
+
begin
|
149
|
+
comp_port = CreateIoCompletionPort(dir_handle, 0, comp_key, 0)
|
170
150
|
|
171
|
-
|
151
|
+
if comp_port == 0
|
172
152
|
raise Error, get_last_error
|
173
153
|
end
|
174
|
-
|
175
|
-
@signaled = true
|
176
|
-
@event.signaled = true
|
177
|
-
|
178
|
-
break if comp_key.unpack('L').first == 0
|
179
|
-
|
180
|
-
yield get_file_action(fni) if block_given?
|
181
|
-
|
154
|
+
|
182
155
|
bool = ReadDirectoryChangesW(
|
183
156
|
dir_handle,
|
184
157
|
fni,
|
@@ -193,13 +166,52 @@ module Win32
|
|
193
166
|
unless bool
|
194
167
|
raise Error, get_last_error
|
195
168
|
end
|
169
|
+
|
170
|
+
while true
|
171
|
+
bool = GetQueuedCompletionStatus(
|
172
|
+
comp_port,
|
173
|
+
qbytes,
|
174
|
+
comp_key,
|
175
|
+
@overlap,
|
176
|
+
seconds
|
177
|
+
)
|
178
|
+
|
179
|
+
unless bool
|
180
|
+
raise Error, get_last_error
|
181
|
+
end
|
182
|
+
|
183
|
+
@signaled = true
|
184
|
+
@event.signaled = true
|
185
|
+
|
186
|
+
break if comp_key.unpack('L').first == 0
|
187
|
+
|
188
|
+
yield get_file_action(fni) if block_given?
|
189
|
+
|
190
|
+
bool = ReadDirectoryChangesW(
|
191
|
+
dir_handle,
|
192
|
+
fni,
|
193
|
+
fni.size,
|
194
|
+
subtree,
|
195
|
+
@filter,
|
196
|
+
rbytes,
|
197
|
+
@overlap,
|
198
|
+
0
|
199
|
+
)
|
200
|
+
|
201
|
+
unless bool
|
202
|
+
raise Error, get_last_error
|
203
|
+
end
|
204
|
+
end
|
205
|
+
ensure
|
206
|
+
CloseHandle(dir_handle)
|
196
207
|
end
|
197
|
-
|
198
|
-
CloseHandle(dir_handle)
|
199
208
|
end
|
200
209
|
|
201
210
|
private
|
202
211
|
|
212
|
+
# Returns an array of ChangeNotify structs, each containing a file name
|
213
|
+
# and an action.
|
214
|
+
#
|
203
215
|
def get_file_action(fni2)
|
204
216
|
fni = fni2.dup
|
205
217
|
array = []
|
@@ -260,4 +272,4 @@ module Win32
|
|
260
272
|
handle
|
261
273
|
end
|
262
274
|
end
|
263
|
-
end
|
275
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#############################################################################
|
2
|
-
#
|
2
|
+
# test_win32_changenotify.rb
|
3
3
|
#
|
4
4
|
# Test suite for the win32-changenotify package. You should run this
|
5
5
|
# test via the 'rake test' task.
|
@@ -8,14 +8,14 @@ require 'test/unit'
|
|
8
8
|
require 'win32/changenotify'
|
9
9
|
include Win32
|
10
10
|
|
11
|
-
class
|
11
|
+
class TC_Win32_ChangeNotify < Test::Unit::TestCase
|
12
12
|
def setup
|
13
13
|
@filter = ChangeNotify::FILE_NAME | ChangeNotify::DIR_NAME
|
14
14
|
@cn = ChangeNotify.new("c:\\", false, @filter)
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_version
|
18
|
-
assert_equal('0.5.
|
18
|
+
assert_equal('0.5.1', ChangeNotify::VERSION)
|
19
19
|
end
|
20
20
|
|
21
21
|
def test_path
|
data/win32-changenotify.gemspec
CHANGED
@@ -2,23 +2,27 @@ require 'rubygems'
|
|
2
2
|
|
3
3
|
spec = Gem::Specification.new do |gem|
|
4
4
|
gem.name = 'win32-changenotify'
|
5
|
-
gem.version = '0.5.
|
5
|
+
gem.version = '0.5.1'
|
6
6
|
gem.author = 'Daniel J. Berger'
|
7
|
+
gem.license = 'Artistic 2.0'
|
7
8
|
gem.email = 'djberg96@gmail.com'
|
8
9
|
gem.homepage = 'http://www.rubyforge.org/projects/win32utils'
|
9
10
|
gem.platform = Gem::Platform::RUBY
|
10
11
|
gem.summary = 'A way to monitor files and directories on MS Windows'
|
11
|
-
gem.
|
12
|
-
gem.test_file = 'test/tc_changenotify.rb'
|
12
|
+
gem.test_file = 'test/test_win32_changenotify.rb'
|
13
13
|
gem.has_rdoc = true
|
14
|
-
gem.files = Dir['
|
15
|
-
|
16
|
-
gem.
|
17
|
-
gem.extra_rdoc_files
|
18
|
-
gem.add_dependency('windows-pr', '>= 0.7.0')
|
19
|
-
end
|
14
|
+
gem.files = Dir['**/*'].reject{ |f| f.include?('CVS') }
|
15
|
+
|
16
|
+
gem.rubyforge_project = 'win32utils'
|
17
|
+
gem.extra_rdoc_files = ['MANIFEST', 'README', 'CHANGES']
|
20
18
|
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
gem.add_dependency('windows-pr', '>= 1.0.6')
|
20
|
+
|
21
|
+
gem.description = <<-EOF
|
22
|
+
The win32-changenotify library provides an interface for monitoring
|
23
|
+
changes in files or diretories on the MS Windows filesystem. It not only
|
24
|
+
tells you when a change occurs, but the nature of the change as well.
|
25
|
+
EOF
|
24
26
|
end
|
27
|
+
|
28
|
+
Gem::Builder.new(spec).build
|
metadata
CHANGED
@@ -1,69 +1,73 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.4
|
3
|
-
specification_version: 1
|
4
2
|
name: win32-changenotify
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.5.
|
7
|
-
date: 2007-08-09 00:00:00 -06:00
|
8
|
-
summary: A way to monitor files and directories on MS Windows
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: djberg96@gmail.com
|
12
|
-
homepage: http://www.rubyforge.org/projects/win32utils
|
13
|
-
rubyforge_project:
|
14
|
-
description: A way to monitor files and directories on MS Windows
|
15
|
-
autorequire:
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 0.5.1
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
7
|
- Daniel J. Berger
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-08-21 00:00:00 -06:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: windows-pr
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.0.6
|
24
|
+
version:
|
25
|
+
description: " The win32-changenotify library provides an interface for monitoring\n changes in files or diretories on the MS Windows filesystem. It not only\n tells you when a change occurs, but the nature of the change as well.\n"
|
26
|
+
email: djberg96@gmail.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- MANIFEST
|
33
|
+
- README
|
34
|
+
- CHANGES
|
31
35
|
files:
|
32
|
-
- lib/win32/changenotify.rb
|
33
|
-
- test/CVS
|
34
|
-
- test/tc_changenotify.rb
|
35
36
|
- CHANGES
|
36
|
-
-
|
37
|
-
-
|
38
|
-
- examples
|
39
|
-
- ext
|
40
|
-
- lib
|
37
|
+
- examples/example_win32_changenotify.rb
|
38
|
+
- lib/win32/changenotify.rb
|
41
39
|
- MANIFEST
|
42
40
|
- Rakefile
|
43
41
|
- README
|
44
|
-
- test
|
42
|
+
- test/test_win32_changenotify.rb
|
45
43
|
- win32-changenotify.gemspec
|
46
|
-
|
47
|
-
|
44
|
+
has_rdoc: true
|
45
|
+
homepage: http://www.rubyforge.org/projects/win32utils
|
46
|
+
licenses:
|
47
|
+
- Artistic 2.0
|
48
|
+
post_install_message:
|
48
49
|
rdoc_options: []
|
49
50
|
|
50
|
-
|
51
|
-
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
version:
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
58
65
|
requirements: []
|
59
66
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 0.7.0
|
69
|
-
version:
|
67
|
+
rubyforge_project: win32utils
|
68
|
+
rubygems_version: 1.3.5
|
69
|
+
signing_key:
|
70
|
+
specification_version: 3
|
71
|
+
summary: A way to monitor files and directories on MS Windows
|
72
|
+
test_files:
|
73
|
+
- test/test_win32_changenotify.rb
|