win32-dir 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,26 +1,26 @@
1
- require 'ffi'
2
-
3
- module Dir::Constants
4
- include FFI::Library
5
-
6
- private
7
-
8
- FILE_DEVICE_FILE_SYSTEM = 0x00000009
9
- FILE_FLAG_OPEN_REPARSE_POINT = 0x00200000
10
- FILE_FLAG_BACKUP_SEMANTICS = 0x02000000
11
- FILE_ATTRIBUTE_DIRECTORY = 0x00000010
12
- FILE_ATTRIBUTE_REPARSE_POINT = 0x00000400
13
- ERROR_ALREADY_EXISTS = 183
14
- METHOD_BUFFERED = 0
15
- OPEN_EXISTING = 3
16
- GENERIC_READ = 0x80000000
17
- GENERIC_WRITE = 0x40000000
18
- SHGFI_DISPLAYNAME = 0x000000200
19
- SHGFI_PIDL = 0x000000008
20
-
21
- # ((DWORD)-1)
22
- INVALID_FILE_ATTRIBUTES = 0xFFFFFFFF
23
-
24
- # ((HANDLE)-1)
25
- INVALID_HANDLE_VALUE = FFI::Pointer.new(-1).address
26
- end
1
+ require 'ffi'
2
+
3
+ module Dir::Constants
4
+ include FFI::Library
5
+
6
+ private
7
+
8
+ FILE_DEVICE_FILE_SYSTEM = 0x00000009
9
+ FILE_FLAG_OPEN_REPARSE_POINT = 0x00200000
10
+ FILE_FLAG_BACKUP_SEMANTICS = 0x02000000
11
+ FILE_ATTRIBUTE_DIRECTORY = 0x00000010
12
+ FILE_ATTRIBUTE_REPARSE_POINT = 0x00000400
13
+ ERROR_ALREADY_EXISTS = 183
14
+ METHOD_BUFFERED = 0
15
+ OPEN_EXISTING = 3
16
+ GENERIC_READ = 0x80000000
17
+ GENERIC_WRITE = 0x40000000
18
+ SHGFI_DISPLAYNAME = 0x000000200
19
+ SHGFI_PIDL = 0x000000008
20
+
21
+ # ((DWORD)-1)
22
+ INVALID_FILE_ATTRIBUTES = 0xFFFFFFFF
23
+
24
+ # ((HANDLE)-1)
25
+ INVALID_HANDLE_VALUE = FFI::Pointer.new(-1).address
26
+ end
@@ -1,66 +1,66 @@
1
- # Necessary to force JRuby to use the gem, not its builtin version
2
- if RUBY_PLATFORM == 'java'
3
- require 'rubygems'
4
- gem 'ffi'
5
- end
6
-
7
- require 'ffi'
8
-
9
- module Dir::Functions
10
- module FFI::Library
11
- # Wrapper method for attach_function + private
12
- def attach_pfunc(*args)
13
- attach_function(*args)
14
- private args[0]
15
- end
16
- end
17
-
18
- extend FFI::Library
19
-
20
- typedef :ulong, :dword
21
- typedef :uintptr_t, :handle
22
- typedef :uintptr_t, :hwnd
23
- typedef :pointer, :ptr
24
-
25
- ffi_lib :shell32
26
- ffi_convention :stdcall
27
-
28
- attach_pfunc :SHGetFolderPathW, [:hwnd, :int, :handle, :dword, :buffer_out], :dword
29
- attach_pfunc :SHGetFolderLocation, [:hwnd, :int, :handle, :dword, :ptr], :dword
30
- attach_pfunc :SHGetFileInfo, [:dword, :dword, :ptr, :uint, :uint], :dword
31
-
32
- ffi_lib :shlwapi
33
- ffi_convention :stdcall
34
-
35
- attach_pfunc :PathIsDirectoryEmptyW, [:buffer_in], :bool
36
-
37
- ffi_lib :kernel32
38
- ffi_convention :stdcall
39
-
40
- attach_pfunc :CloseHandle, [:handle], :bool
41
- attach_pfunc :CreateDirectoryW, [:buffer_in, :ptr], :bool
42
- attach_pfunc :CreateFileW, [:buffer_in, :dword, :dword, :ptr, :dword, :dword, :handle], :handle
43
- attach_pfunc :DeviceIoControl, [:handle, :dword, :ptr, :dword, :ptr, :dword, :ptr, :ptr], :bool
44
- attach_pfunc :GetCurrentDirectoryW, [:dword, :buffer_out], :dword
45
- attach_pfunc :GetFileAttributesW, [:buffer_in], :dword
46
- attach_pfunc :GetLastError, [], :dword
47
- attach_pfunc :GetShortPathNameW, [:buffer_in, :buffer_out, :dword], :dword
48
- attach_pfunc :GetLongPathNameW, [:buffer_in, :buffer_out, :dword], :dword
49
- attach_pfunc :GetFullPathNameW, [:buffer_in, :dword, :buffer_out, :ptr], :dword
50
- attach_pfunc :RemoveDirectoryW, [:buffer_in], :bool
51
- end
52
-
53
- class String
54
- # Convenience method for converting strings to UTF-16LE for wide character
55
- # functions that require it.
56
- def wincode
57
- (self.tr(File::SEPARATOR, File::ALT_SEPARATOR) + 0.chr).encode('UTF-16LE')
58
- end
59
-
60
- # Read a wide character string up until the first double null, and delete
61
- # any remaining null characters.
62
- def wstrip
63
- self.force_encoding('UTF-16LE').encode('UTF-8',:invalid=>:replace,:undef=>:replace).
64
- split("\x00")[0].encode(Encoding.default_external)
65
- end
66
- end
1
+ # Necessary to force JRuby to use the gem, not its builtin version
2
+ if RUBY_PLATFORM == 'java'
3
+ require 'rubygems'
4
+ gem 'ffi'
5
+ end
6
+
7
+ require 'ffi'
8
+
9
+ module Dir::Functions
10
+ module FFI::Library
11
+ # Wrapper method for attach_function + private
12
+ def attach_pfunc(*args)
13
+ attach_function(*args)
14
+ private args[0]
15
+ end
16
+ end
17
+
18
+ extend FFI::Library
19
+
20
+ typedef :ulong, :dword
21
+ typedef :uintptr_t, :handle
22
+ typedef :uintptr_t, :hwnd
23
+ typedef :pointer, :ptr
24
+
25
+ ffi_lib :shell32
26
+ ffi_convention :stdcall
27
+
28
+ attach_pfunc :SHGetFolderPathW, [:hwnd, :int, :handle, :dword, :buffer_out], :dword
29
+ attach_pfunc :SHGetFolderLocation, [:hwnd, :int, :handle, :dword, :ptr], :dword
30
+ attach_pfunc :SHGetFileInfo, [:dword, :dword, :ptr, :uint, :uint], :dword
31
+
32
+ ffi_lib :shlwapi
33
+ ffi_convention :stdcall
34
+
35
+ attach_pfunc :PathIsDirectoryEmptyW, [:buffer_in], :bool
36
+
37
+ ffi_lib :kernel32
38
+ ffi_convention :stdcall
39
+
40
+ attach_pfunc :CloseHandle, [:handle], :bool
41
+ attach_pfunc :CreateDirectoryW, [:buffer_in, :ptr], :bool
42
+ attach_pfunc :CreateFileW, [:buffer_in, :dword, :dword, :ptr, :dword, :dword, :handle], :handle
43
+ attach_pfunc :DeviceIoControl, [:handle, :dword, :ptr, :dword, :ptr, :dword, :ptr, :ptr], :bool
44
+ attach_pfunc :GetCurrentDirectoryW, [:dword, :buffer_out], :dword
45
+ attach_pfunc :GetFileAttributesW, [:buffer_in], :dword
46
+ attach_pfunc :GetLastError, [], :dword
47
+ attach_pfunc :GetShortPathNameW, [:buffer_in, :buffer_out, :dword], :dword
48
+ attach_pfunc :GetLongPathNameW, [:buffer_in, :buffer_out, :dword], :dword
49
+ attach_pfunc :GetFullPathNameW, [:buffer_in, :dword, :buffer_out, :ptr], :dword
50
+ attach_pfunc :RemoveDirectoryW, [:buffer_in], :bool
51
+ end
52
+
53
+ class String
54
+ # Convenience method for converting strings to UTF-16LE for wide character
55
+ # functions that require it.
56
+ def wincode
57
+ (self.tr(File::SEPARATOR, File::ALT_SEPARATOR) + 0.chr).encode('UTF-16LE')
58
+ end
59
+
60
+ # Read a wide character string up until the first double null, and delete
61
+ # any remaining null characters.
62
+ def wstrip
63
+ self.force_encoding('UTF-16LE').encode('UTF-8',:invalid=>:replace,:undef=>:replace).
64
+ split("\x00")[0].encode(Encoding.default_external)
65
+ end
66
+ end
@@ -1,37 +1,37 @@
1
- require 'ffi'
2
-
3
- module Dir::Structs
4
- extend FFI::Library
5
-
6
- class SHFILEINFO < FFI::Struct
7
- layout(
8
- :hIcon, :ulong,
9
- :iIcon, :int,
10
- :dwAttributes, :ulong,
11
- :szDisplayName, [:char, 256],
12
- :szTypeName, [:char, 80]
13
- )
14
- end
15
-
16
- # I fudge a bit, assuming a MountPointReparseBuffer
17
- class REPARSE_JDATA_BUFFER < FFI::Struct
18
- layout(
19
- :ReparseTag, :ulong,
20
- :ReparseDataLength, :ushort,
21
- :Reserved, :ushort,
22
- :SubstituteNameOffset, :ushort,
23
- :SubstituteNameLength, :ushort,
24
- :PrintNameOffset, :ushort,
25
- :PrintNameLength, :ushort,
26
- :PathBuffer, [:char, 1024]
27
- )
28
-
29
- # The REPARSE_DATA_BUFFER_HEADER_SIZE which is calculated as:
30
- #
31
- # sizeof(ReparseTag) + sizeof(ReparseDataLength) + sizeof(Reserved)
32
- #
33
- def header_size
34
- FFI::Type::ULONG.size + FFI::Type::USHORT.size + FFI::Type::USHORT.size
35
- end
36
- end
37
- end
1
+ require 'ffi'
2
+
3
+ module Dir::Structs
4
+ extend FFI::Library
5
+
6
+ class SHFILEINFO < FFI::Struct
7
+ layout(
8
+ :hIcon, :ulong,
9
+ :iIcon, :int,
10
+ :dwAttributes, :ulong,
11
+ :szDisplayName, [:char, 256],
12
+ :szTypeName, [:char, 80]
13
+ )
14
+ end
15
+
16
+ # I fudge a bit, assuming a MountPointReparseBuffer
17
+ class REPARSE_JDATA_BUFFER < FFI::Struct
18
+ layout(
19
+ :ReparseTag, :ulong,
20
+ :ReparseDataLength, :ushort,
21
+ :Reserved, :ushort,
22
+ :SubstituteNameOffset, :ushort,
23
+ :SubstituteNameLength, :ushort,
24
+ :PrintNameOffset, :ushort,
25
+ :PrintNameLength, :ushort,
26
+ :PathBuffer, [:char, 1024]
27
+ )
28
+
29
+ # The REPARSE_DATA_BUFFER_HEADER_SIZE which is calculated as:
30
+ #
31
+ # sizeof(ReparseTag) + sizeof(ReparseDataLength) + sizeof(Reserved)
32
+ #
33
+ def header_size
34
+ FFI::Type::ULONG.size + FFI::Type::USHORT.size + FFI::Type::USHORT.size
35
+ end
36
+ end
37
+ end
@@ -1,466 +1,466 @@
1
- # encoding: utf-8
2
- ###########################################################################
3
- # test_win32_dir.rb
4
- #
5
- # Test suite for the win32-dir library. You should run this test case
6
- # via the 'rake test' task.
7
- ###########################################################################
8
- require 'test-unit'
9
- require 'win32/dir'
10
- require 'tmpdir'
11
- require 'fileutils'
12
- require 'pathname'
13
-
14
- class TC_Win32_Dir < Test::Unit::TestCase
15
- def self.startup
16
- @@java = RUBY_PLATFORM == 'java'
17
- @@temp = Dir.tmpdir
18
- @@from = File.join(@@temp, "test_from_directory")
19
- Dir.mkdir(@@from)
20
- end
21
-
22
- def setup
23
- @ascii_to = File.join(@@temp, "test_to_directory")
24
- @unicode_to = File.join(@@temp, "Ελλάσ")
25
- @test_file = File.join(@@from, "test.txt")
26
- end
27
-
28
- test "version number is set to expected value" do
29
- assert_equal('0.5.0', Dir::VERSION)
30
- end
31
-
32
- test 'glob handles backslashes' do
33
- pattern = "C:\\Program Files\\Common Files\\System\\*.dll"
34
- assert_nothing_raised{ Dir.glob(pattern) }
35
- assert_true(Dir.glob(pattern).size > 0)
36
- end
37
-
38
- test 'glob handles multiple strings' do
39
- pattern1 = "C:\\Program Files\\Common Files\\System\\*.dll"
40
- pattern2 = "C:\\Windows\\*.exe"
41
- assert_nothing_raised{ Dir.glob([pattern1, pattern2]) }
42
- assert_true(Dir.glob([pattern1, pattern2]).size > 0)
43
- end
44
-
45
- test 'glob still observes flags' do
46
- assert_nothing_raised{ Dir.glob('*', File::FNM_DOTMATCH ) }
47
- assert_true(Dir.glob('*', File::FNM_DOTMATCH).include?('.'))
48
- end
49
-
50
- test 'glob still honors block' do
51
- array = []
52
- assert_nothing_raised{ Dir.glob('*', File::FNM_DOTMATCH ){ |m| array << m } }
53
- assert_true(array.include?('.'))
54
- end
55
-
56
- test 'glob handles Pathname objects' do
57
- pattern1 = Pathname.new("C:\\Program Files\\Common Files\\System\\*.dll")
58
- pattern2 = Pathname.new("C:\\Windows\\*.exe")
59
- assert_nothing_raised{ Dir.glob([pattern1, pattern2]) }
60
- assert_true(Dir.glob([pattern1, pattern2]).size > 0)
61
- end
62
-
63
- test "glob requires a stringy argument" do
64
- assert_raise(TypeError){ Dir.glob(nil) }
65
- end
66
-
67
- test 'ref handles backslashes' do
68
- pattern = "C:\\Program Files\\Common Files\\System\\*.dll"
69
- assert_nothing_raised{ Dir[pattern] }
70
- assert_true(Dir[pattern].size > 0)
71
- end
72
-
73
- test 'ref handles multiple arguments' do
74
- pattern1 = "C:\\Program Files\\Common Files\\System\\*.dll"
75
- pattern2 = "C:\\Windows\\*.exe"
76
- assert_nothing_raised{ Dir[pattern1, pattern2] }
77
- assert_true(Dir[pattern1, pattern2].size > 0)
78
- end
79
-
80
- test 'ref handles pathname arguments' do
81
- pattern1 = Pathname.new("C:\\Program Files\\Common Files\\System\\*.dll")
82
- pattern2 = Pathname.new("C:\\Windows\\*.exe")
83
- assert_nothing_raised{ Dir[pattern1, pattern2] }
84
- assert_true(Dir[pattern1, pattern2].size > 0)
85
- end
86
-
87
- test "create_junction basic functionality" do
88
- assert_respond_to(Dir, :create_junction)
89
- end
90
-
91
- test "create_junction works as expected with ascii characters" do
92
- assert_nothing_raised{ Dir.create_junction(@ascii_to, @@from) }
93
- assert_true(File.exist?(@ascii_to))
94
- File.open(@test_file, 'w'){ |fh| fh.puts "Hello World" }
95
- assert_equal(Dir.entries(@@from), Dir.entries(@ascii_to))
96
- end
97
-
98
- test "create_junction works as expected with unicode characters" do
99
- assert_nothing_raised{ Dir.create_junction(@unicode_to, @@from) }
100
- assert_true(File.exist?(@unicode_to))
101
- File.open(@test_file, 'w'){ |fh| fh.puts "Hello World" }
102
- assert_equal(Dir.entries(@@from), Dir.entries(@unicode_to))
103
- end
104
-
105
- test "create_junction works as expected with pathname objects" do
106
- assert_nothing_raised{ Dir.create_junction(Pathname.new(@ascii_to), Pathname.new(@@from)) }
107
- assert_true(File.exist?(@ascii_to))
108
- File.open(@test_file, 'w'){ |fh| fh.puts "Hello World" }
109
- assert_equal(Dir.entries(@@from), Dir.entries(@ascii_to))
110
- end
111
-
112
- test "create_junction requires stringy arguments" do
113
- assert_raise(TypeError){ Dir.create_junction(nil, @@from) }
114
- assert_raise(TypeError){ Dir.create_junction(@ascii_to, nil) }
115
- end
116
-
117
- test "read_junction works as expected with ascii characters" do
118
- assert_nothing_raised{ Dir.create_junction(@ascii_to, @@from) }
119
- assert_true(File.exist?(@ascii_to))
120
- assert_equal(Dir.read_junction(@ascii_to), @@from)
121
- end
122
-
123
- test "read_junction works as expected with unicode characters" do
124
- assert_nothing_raised{ Dir.create_junction(@unicode_to, @@from) }
125
- assert_true(File.exist?(@unicode_to))
126
- assert_equal(Dir.read_junction(@unicode_to), @@from)
127
- end
128
-
129
- test "read_junction with unicode characters is joinable" do
130
- assert_nothing_raised{ Dir.create_junction(@unicode_to, @@from) }
131
- assert_true(File.exist?(@unicode_to))
132
- assert_nothing_raised{ File.join(Dir.read_junction(@unicode_to), 'foo') }
133
- end
134
-
135
- test "read_junction works as expected with pathname objects" do
136
- assert_nothing_raised{ Dir.create_junction(Pathname.new(@ascii_to), Pathname.new(@@from)) }
137
- assert_true(File.exist?(@ascii_to))
138
- assert_equal(Dir.read_junction(@ascii_to), @@from)
139
- end
140
-
141
- test "read_junction requires a stringy argument" do
142
- assert_raise(TypeError){ Dir.read_junction(nil) }
143
- assert_raise(TypeError){ Dir.read_junction([]) }
144
- end
145
-
146
- test "junction? method returns boolean value" do
147
- assert_respond_to(Dir, :junction?)
148
- assert_nothing_raised{ Dir.create_junction(@ascii_to, @@from) }
149
- assert_false(Dir.junction?(@@from))
150
- assert_true(Dir.junction?(@ascii_to))
151
- assert_true(Dir.junction?(Pathname.new(@ascii_to)))
152
- end
153
-
154
- test "reparse_dir? is an aliase for junction?" do
155
- assert_respond_to(Dir, :reparse_dir?)
156
- assert_true(Dir.method(:reparse_dir?) == Dir.method(:junction?))
157
- end
158
-
159
- test "empty? method returns expected result" do
160
- assert_respond_to(Dir, :empty?)
161
- assert_false(Dir.empty?("C:\\")) # One would think
162
- assert_true(Dir.empty?(@@from))
163
- assert_true(Dir.empty?(Pathname.new(@@from)))
164
- end
165
-
166
- test "pwd basic functionality" do
167
- omit_if(@@java)
168
- assert_respond_to(Dir, :pwd)
169
- assert_nothing_raised{ Dir.pwd }
170
- assert_kind_of(String, Dir.pwd)
171
- end
172
-
173
- test "pwd returns full path even if short path was just used" do
174
- omit_if(@@java)
175
- Dir.chdir("C:\\Progra~1")
176
- assert_equal("C:\\Program Files", Dir.pwd)
177
- end
178
-
179
- test "pwd returns full path if long path was just used" do
180
- omit_if(@@java)
181
- Dir.chdir("C:\\Program Files")
182
- assert_equal("C:\\Program Files", Dir.pwd)
183
- end
184
-
185
- test "pwd uses standard case conventions" do
186
- omit_if(@@java)
187
- Dir.chdir("C:\\PROGRAM FILES")
188
- assert_equal("C:\\Program Files", Dir.pwd)
189
- end
190
-
191
- test "pwd converts forward slashes to backslashes" do
192
- omit_if(@@java)
193
- Dir.chdir("C:/Program Files")
194
- assert_equal("C:\\Program Files", Dir.pwd)
195
- end
196
-
197
- test "pwd and getwd are aliases" do
198
- omit_if(@@java)
199
- assert_true(Dir.method(:getwd) == Dir.method(:pwd))
200
- end
201
-
202
- test "admintools constant is set" do
203
- assert_not_nil(Dir::ADMINTOOLS)
204
- assert_kind_of(String, Dir::ADMINTOOLS)
205
- end
206
-
207
- test "altstartup constant is set" do
208
- assert_not_nil(Dir::ALTSTARTUP)
209
- assert_kind_of(String, Dir::ALTSTARTUP)
210
- end
211
-
212
- test "appdata constant is set" do
213
- assert_not_nil(Dir::APPDATA)
214
- assert_kind_of(String, Dir::APPDATA)
215
- end
216
-
217
- test "bitbucket constant is set" do
218
- assert_not_nil(Dir::BITBUCKET)
219
- assert_kind_of(String, Dir::BITBUCKET)
220
- end
221
-
222
- test "cdburn area is set" do
223
- assert_not_nil(Dir::CDBURN_AREA)
224
- assert_kind_of(String, Dir::CDBURN_AREA)
225
- end
226
-
227
- test "common admintools is set" do
228
- assert_not_nil(Dir::COMMON_ADMINTOOLS)
229
- assert_kind_of(String, Dir::COMMON_ADMINTOOLS)
230
- end
231
-
232
- test "common_altstartup constant is set" do
233
- assert_not_nil(Dir::COMMON_ALTSTARTUP)
234
- assert_kind_of(String, Dir::COMMON_ALTSTARTUP)
235
- end
236
-
237
- test "common_appdata constant is set" do
238
- assert_not_nil(Dir::COMMON_APPDATA)
239
- assert_kind_of(String, Dir::COMMON_APPDATA)
240
- end
241
-
242
- test "common desktopdirectory constant is set" do
243
- assert_not_nil(Dir::COMMON_DESKTOPDIRECTORY)
244
- assert_kind_of(String, Dir::COMMON_DESKTOPDIRECTORY)
245
- end
246
-
247
- test "common_documents constant is set" do
248
- assert_not_nil(Dir::COMMON_DOCUMENTS)
249
- assert_kind_of(String, Dir::COMMON_DOCUMENTS)
250
- end
251
-
252
- test "common_favorites constant is set" do
253
- assert_not_nil(Dir::COMMON_FAVORITES)
254
- assert_kind_of(String, Dir::COMMON_FAVORITES)
255
- end
256
-
257
- test "common_music constant is set" do
258
- assert_not_nil(Dir::COMMON_MUSIC)
259
- assert_kind_of(String, Dir::COMMON_MUSIC)
260
- end
261
-
262
- test "common_pictures constant is set" do
263
- assert_not_nil(Dir::COMMON_PICTURES)
264
- assert_kind_of(String, Dir::COMMON_PICTURES)
265
- end
266
-
267
- test "common_programs constant is set" do
268
- assert_not_nil(Dir::COMMON_PROGRAMS)
269
- assert_kind_of(String, Dir::COMMON_PROGRAMS)
270
- end
271
-
272
- test "common_startmenu constant is set" do
273
- assert_not_nil(Dir::COMMON_STARTMENU)
274
- assert_kind_of(String, Dir::COMMON_STARTMENU)
275
- end
276
-
277
- test "common_startup constant is set" do
278
- assert_not_nil(Dir::COMMON_STARTUP)
279
- assert_kind_of(String, Dir::COMMON_STARTUP)
280
- end
281
-
282
- test "common_templates constant is set" do
283
- assert_not_nil(Dir::COMMON_TEMPLATES)
284
- assert_kind_of(String, Dir::COMMON_TEMPLATES)
285
- end
286
-
287
- test "common_video constant is set" do
288
- assert_not_nil(Dir::COMMON_VIDEO)
289
- assert_kind_of(String, Dir::COMMON_VIDEO)
290
- end
291
-
292
- test "controls constant is set" do
293
- assert_not_nil(Dir::CONTROLS)
294
- assert_kind_of(String, Dir::CONTROLS)
295
- end
296
-
297
- test "cookies constant is set" do
298
- assert_not_nil(Dir::COOKIES)
299
- assert_kind_of(String, Dir::COOKIES)
300
- end
301
-
302
- test "desktop constant is set" do
303
- assert_not_nil(Dir::DESKTOP)
304
- assert_kind_of(String, Dir::DESKTOP)
305
- end
306
-
307
- test "desktopdirectory is set" do
308
- assert_not_nil(Dir::DESKTOPDIRECTORY)
309
- assert_kind_of(String, Dir::DESKTOPDIRECTORY)
310
- end
311
-
312
- test "drives constant is set" do
313
- assert_not_nil(Dir::DRIVES)
314
- assert_kind_of(String, Dir::DRIVES)
315
- end
316
-
317
- test "favorites constant is set" do
318
- assert_not_nil(Dir::FAVORITES)
319
- assert_kind_of(String, Dir::FAVORITES)
320
- end
321
-
322
- test "fonts constant is set" do
323
- assert_not_nil(Dir::FONTS)
324
- assert_kind_of(String, Dir::FONTS)
325
- end
326
-
327
- test "history constant is set" do
328
- assert_not_nil(Dir::HISTORY)
329
- assert_kind_of(String, Dir::HISTORY)
330
- end
331
-
332
- test "internet constant is set" do
333
- assert_not_nil(Dir::INTERNET)
334
- assert_kind_of(String, Dir::INTERNET)
335
- end
336
-
337
- test "internet_cache constant is set" do
338
- assert_not_nil(Dir::INTERNET_CACHE)
339
- assert_kind_of(String, Dir::INTERNET_CACHE)
340
- end
341
-
342
- test "local_appdata constant is set" do
343
- assert_not_nil(Dir::LOCAL_APPDATA)
344
- assert_kind_of(String, Dir::LOCAL_APPDATA)
345
- end
346
-
347
- test "mydocuments constant is set" do
348
- assert_not_nil(Dir::MYDOCUMENTS)
349
- assert_kind_of(String, Dir::MYDOCUMENTS)
350
- end
351
-
352
- test "mymusic constant is set" do
353
- assert_not_nil(Dir::MYMUSIC)
354
- assert_kind_of(String, Dir::MYMUSIC)
355
- end
356
-
357
- test "mypictures constant is set" do
358
- assert_not_nil(Dir::MYPICTURES)
359
- assert_kind_of(String, Dir::MYPICTURES)
360
- end
361
-
362
- test "myvideo constant is set" do
363
- assert_not_nil(Dir::MYVIDEO)
364
- assert_kind_of(String, Dir::MYVIDEO)
365
- end
366
-
367
- test "nethood constant is set" do
368
- assert_not_nil(Dir::NETHOOD)
369
- assert_kind_of(String, Dir::NETHOOD)
370
- end
371
-
372
- test "network constant is set" do
373
- assert_not_nil(Dir::NETWORK)
374
- assert_kind_of(String, Dir::NETWORK)
375
- end
376
-
377
- test "personal constant is set" do
378
- assert_not_nil(Dir::PERSONAL)
379
- assert_kind_of(String, Dir::PERSONAL)
380
- end
381
-
382
- test "printers cosntant is set" do
383
- assert_not_nil(Dir::PRINTERS)
384
- assert_kind_of(String, Dir::PRINTERS)
385
- end
386
-
387
- test "printhood constant is set" do
388
- assert_not_nil(Dir::PRINTHOOD)
389
- assert_kind_of(String, Dir::PRINTHOOD)
390
- end
391
-
392
- test "profile constant is set" do
393
- assert_not_nil(Dir::PROFILE)
394
- assert_kind_of(String, Dir::PROFILE)
395
- end
396
-
397
- test "program_files constant is set" do
398
- assert_not_nil(Dir::PROGRAM_FILES)
399
- assert_kind_of(String, Dir::PROGRAM_FILES)
400
- end
401
-
402
- test "program_files_common constant is set" do
403
- assert_not_nil(Dir::PROGRAM_FILES_COMMON)
404
- assert_kind_of(String, Dir::PROGRAM_FILES_COMMON)
405
- end
406
-
407
- test "programs constant is set" do
408
- assert_not_nil(Dir::PROGRAMS)
409
- assert_kind_of(String, Dir::PROGRAMS)
410
- end
411
-
412
- test "recent constant is set" do
413
- assert_not_nil(Dir::RECENT)
414
- assert_kind_of(String, Dir::RECENT)
415
- end
416
-
417
- test "sendto constant is set" do
418
- assert_not_nil(Dir::SENDTO)
419
- assert_kind_of(String, Dir::SENDTO)
420
- end
421
-
422
- test "startmenu constant is set" do
423
- assert_not_nil(Dir::STARTMENU)
424
- assert_kind_of(String, Dir::STARTMENU)
425
- end
426
-
427
- test "startup constant is set" do
428
- assert_not_nil(Dir::STARTUP)
429
- assert_kind_of(String, Dir::STARTUP)
430
- end
431
-
432
- test "system constant is set" do
433
- assert_not_nil(Dir::SYSTEM)
434
- assert_kind_of(String, Dir::SYSTEM)
435
- end
436
-
437
- test "templates constant is set" do
438
- assert_not_nil(Dir::TEMPLATES)
439
- assert_kind_of(String, Dir::TEMPLATES)
440
- end
441
-
442
- test "windows constant is set" do
443
- assert_not_nil(Dir::WINDOWS)
444
- assert_kind_of(String, Dir::WINDOWS)
445
- end
446
-
447
- test "constants are ascii_compatible?" do
448
- assert_true(Dir::COMMON_APPDATA.encoding.ascii_compatible?)
449
- assert_nothing_raised{ File.join(Dir::COMMON_APPDATA, 'foo') }
450
- end
451
-
452
- test "ffi functions are private" do
453
- assert_not_respond_to(Dir, :SHGetFolderPathW)
454
- end
455
-
456
- def teardown
457
- FileUtils.rm_rf(@ascii_to)
458
- FileUtils.rm_rf(@unicode_to)
459
- end
460
-
461
- def self.shutdown
462
- FileUtils.rm_rf(@@from)
463
- @@test_home = nil
464
- @@from = nil
465
- end
466
- end
1
+ # encoding: utf-8
2
+ ###########################################################################
3
+ # test_win32_dir.rb
4
+ #
5
+ # Test suite for the win32-dir library. You should run this test case
6
+ # via the 'rake test' task.
7
+ ###########################################################################
8
+ require 'test-unit'
9
+ require 'win32/dir'
10
+ require 'tmpdir'
11
+ require 'fileutils'
12
+ require 'pathname'
13
+
14
+ class TC_Win32_Dir < Test::Unit::TestCase
15
+ def self.startup
16
+ @@java = RUBY_PLATFORM == 'java'
17
+ @@temp = Dir.tmpdir
18
+ @@from = File.join(@@temp, "test_from_directory")
19
+ Dir.mkdir(@@from)
20
+ end
21
+
22
+ def setup
23
+ @ascii_to = File.join(@@temp, "test_to_directory")
24
+ @unicode_to = File.join(@@temp, "Ελλάσ")
25
+ @test_file = File.join(@@from, "test.txt")
26
+ end
27
+
28
+ test "version number is set to expected value" do
29
+ assert_equal('0.5.1', Dir::VERSION)
30
+ end
31
+
32
+ test 'glob handles backslashes' do
33
+ pattern = "C:\\Program Files\\Common Files\\System\\*.dll"
34
+ assert_nothing_raised{ Dir.glob(pattern) }
35
+ assert_true(Dir.glob(pattern).size > 0)
36
+ end
37
+
38
+ test 'glob handles multiple strings' do
39
+ pattern1 = "C:\\Program Files\\Common Files\\System\\*.dll"
40
+ pattern2 = "C:\\Windows\\*.exe"
41
+ assert_nothing_raised{ Dir.glob([pattern1, pattern2]) }
42
+ assert_true(Dir.glob([pattern1, pattern2]).size > 0)
43
+ end
44
+
45
+ test 'glob still observes flags' do
46
+ assert_nothing_raised{ Dir.glob('*', File::FNM_DOTMATCH ) }
47
+ assert_true(Dir.glob('*', File::FNM_DOTMATCH).include?('.'))
48
+ end
49
+
50
+ test 'glob still honors block' do
51
+ array = []
52
+ assert_nothing_raised{ Dir.glob('*', File::FNM_DOTMATCH ){ |m| array << m } }
53
+ assert_true(array.include?('.'))
54
+ end
55
+
56
+ test 'glob handles Pathname objects' do
57
+ pattern1 = Pathname.new("C:\\Program Files\\Common Files\\System\\*.dll")
58
+ pattern2 = Pathname.new("C:\\Windows\\*.exe")
59
+ assert_nothing_raised{ Dir.glob([pattern1, pattern2]) }
60
+ assert_true(Dir.glob([pattern1, pattern2]).size > 0)
61
+ end
62
+
63
+ test "glob requires a stringy argument" do
64
+ assert_raise(TypeError){ Dir.glob(nil) }
65
+ end
66
+
67
+ test 'ref handles backslashes' do
68
+ pattern = "C:\\Program Files\\Common Files\\System\\*.dll"
69
+ assert_nothing_raised{ Dir[pattern] }
70
+ assert_true(Dir[pattern].size > 0)
71
+ end
72
+
73
+ test 'ref handles multiple arguments' do
74
+ pattern1 = "C:\\Program Files\\Common Files\\System\\*.dll"
75
+ pattern2 = "C:\\Windows\\*.exe"
76
+ assert_nothing_raised{ Dir[pattern1, pattern2] }
77
+ assert_true(Dir[pattern1, pattern2].size > 0)
78
+ end
79
+
80
+ test 'ref handles pathname arguments' do
81
+ pattern1 = Pathname.new("C:\\Program Files\\Common Files\\System\\*.dll")
82
+ pattern2 = Pathname.new("C:\\Windows\\*.exe")
83
+ assert_nothing_raised{ Dir[pattern1, pattern2] }
84
+ assert_true(Dir[pattern1, pattern2].size > 0)
85
+ end
86
+
87
+ test "create_junction basic functionality" do
88
+ assert_respond_to(Dir, :create_junction)
89
+ end
90
+
91
+ test "create_junction works as expected with ascii characters" do
92
+ assert_nothing_raised{ Dir.create_junction(@ascii_to, @@from) }
93
+ assert_true(File.exist?(@ascii_to))
94
+ File.open(@test_file, 'w'){ |fh| fh.puts "Hello World" }
95
+ assert_equal(Dir.entries(@@from), Dir.entries(@ascii_to))
96
+ end
97
+
98
+ test "create_junction works as expected with unicode characters" do
99
+ assert_nothing_raised{ Dir.create_junction(@unicode_to, @@from) }
100
+ assert_true(File.exist?(@unicode_to))
101
+ File.open(@test_file, 'w'){ |fh| fh.puts "Hello World" }
102
+ assert_equal(Dir.entries(@@from), Dir.entries(@unicode_to))
103
+ end
104
+
105
+ test "create_junction works as expected with pathname objects" do
106
+ assert_nothing_raised{ Dir.create_junction(Pathname.new(@ascii_to), Pathname.new(@@from)) }
107
+ assert_true(File.exist?(@ascii_to))
108
+ File.open(@test_file, 'w'){ |fh| fh.puts "Hello World" }
109
+ assert_equal(Dir.entries(@@from), Dir.entries(@ascii_to))
110
+ end
111
+
112
+ test "create_junction requires stringy arguments" do
113
+ assert_raise(TypeError){ Dir.create_junction(nil, @@from) }
114
+ assert_raise(TypeError){ Dir.create_junction(@ascii_to, nil) }
115
+ end
116
+
117
+ test "read_junction works as expected with ascii characters" do
118
+ assert_nothing_raised{ Dir.create_junction(@ascii_to, @@from) }
119
+ assert_true(File.exist?(@ascii_to))
120
+ assert_equal(Dir.read_junction(@ascii_to), @@from)
121
+ end
122
+
123
+ test "read_junction works as expected with unicode characters" do
124
+ assert_nothing_raised{ Dir.create_junction(@unicode_to, @@from) }
125
+ assert_true(File.exist?(@unicode_to))
126
+ assert_equal(Dir.read_junction(@unicode_to), @@from)
127
+ end
128
+
129
+ test "read_junction with unicode characters is joinable" do
130
+ assert_nothing_raised{ Dir.create_junction(@unicode_to, @@from) }
131
+ assert_true(File.exist?(@unicode_to))
132
+ assert_nothing_raised{ File.join(Dir.read_junction(@unicode_to), 'foo') }
133
+ end
134
+
135
+ test "read_junction works as expected with pathname objects" do
136
+ assert_nothing_raised{ Dir.create_junction(Pathname.new(@ascii_to), Pathname.new(@@from)) }
137
+ assert_true(File.exist?(@ascii_to))
138
+ assert_equal(Dir.read_junction(@ascii_to), @@from)
139
+ end
140
+
141
+ test "read_junction requires a stringy argument" do
142
+ assert_raise(TypeError){ Dir.read_junction(nil) }
143
+ assert_raise(TypeError){ Dir.read_junction([]) }
144
+ end
145
+
146
+ test "junction? method returns boolean value" do
147
+ assert_respond_to(Dir, :junction?)
148
+ assert_nothing_raised{ Dir.create_junction(@ascii_to, @@from) }
149
+ assert_false(Dir.junction?(@@from))
150
+ assert_true(Dir.junction?(@ascii_to))
151
+ assert_true(Dir.junction?(Pathname.new(@ascii_to)))
152
+ end
153
+
154
+ test "reparse_dir? is an aliase for junction?" do
155
+ assert_respond_to(Dir, :reparse_dir?)
156
+ assert_true(Dir.method(:reparse_dir?) == Dir.method(:junction?))
157
+ end
158
+
159
+ test "empty? method returns expected result" do
160
+ assert_respond_to(Dir, :empty?)
161
+ assert_false(Dir.empty?("C:\\")) # One would think
162
+ assert_true(Dir.empty?(@@from))
163
+ assert_true(Dir.empty?(Pathname.new(@@from)))
164
+ end
165
+
166
+ test "pwd basic functionality" do
167
+ omit_if(@@java)
168
+ assert_respond_to(Dir, :pwd)
169
+ assert_nothing_raised{ Dir.pwd }
170
+ assert_kind_of(String, Dir.pwd)
171
+ end
172
+
173
+ test "pwd returns full path even if short path was just used" do
174
+ omit_if(@@java)
175
+ Dir.chdir("C:\\Progra~1")
176
+ assert_equal("C:\\Program Files", Dir.pwd)
177
+ end
178
+
179
+ test "pwd returns full path if long path was just used" do
180
+ omit_if(@@java)
181
+ Dir.chdir("C:\\Program Files")
182
+ assert_equal("C:\\Program Files", Dir.pwd)
183
+ end
184
+
185
+ test "pwd uses standard case conventions" do
186
+ omit_if(@@java)
187
+ Dir.chdir("C:\\PROGRAM FILES")
188
+ assert_equal("C:\\Program Files", Dir.pwd)
189
+ end
190
+
191
+ test "pwd converts forward slashes to backslashes" do
192
+ omit_if(@@java)
193
+ Dir.chdir("C:/Program Files")
194
+ assert_equal("C:\\Program Files", Dir.pwd)
195
+ end
196
+
197
+ test "pwd and getwd are aliases" do
198
+ omit_if(@@java)
199
+ assert_true(Dir.method(:getwd) == Dir.method(:pwd))
200
+ end
201
+
202
+ test "admintools constant is set" do
203
+ assert_not_nil(Dir::ADMINTOOLS)
204
+ assert_kind_of(String, Dir::ADMINTOOLS)
205
+ end
206
+
207
+ test "altstartup constant is set" do
208
+ assert_not_nil(Dir::ALTSTARTUP)
209
+ assert_kind_of(String, Dir::ALTSTARTUP)
210
+ end
211
+
212
+ test "appdata constant is set" do
213
+ assert_not_nil(Dir::APPDATA)
214
+ assert_kind_of(String, Dir::APPDATA)
215
+ end
216
+
217
+ test "bitbucket constant is set" do
218
+ assert_not_nil(Dir::BITBUCKET)
219
+ assert_kind_of(String, Dir::BITBUCKET)
220
+ end
221
+
222
+ test "cdburn area is set" do
223
+ assert_not_nil(Dir::CDBURN_AREA)
224
+ assert_kind_of(String, Dir::CDBURN_AREA)
225
+ end
226
+
227
+ test "common admintools is set" do
228
+ assert_not_nil(Dir::COMMON_ADMINTOOLS)
229
+ assert_kind_of(String, Dir::COMMON_ADMINTOOLS)
230
+ end
231
+
232
+ test "common_altstartup constant is set" do
233
+ assert_not_nil(Dir::COMMON_ALTSTARTUP)
234
+ assert_kind_of(String, Dir::COMMON_ALTSTARTUP)
235
+ end
236
+
237
+ test "common_appdata constant is set" do
238
+ assert_not_nil(Dir::COMMON_APPDATA)
239
+ assert_kind_of(String, Dir::COMMON_APPDATA)
240
+ end
241
+
242
+ test "common desktopdirectory constant is set" do
243
+ assert_not_nil(Dir::COMMON_DESKTOPDIRECTORY)
244
+ assert_kind_of(String, Dir::COMMON_DESKTOPDIRECTORY)
245
+ end
246
+
247
+ test "common_documents constant is set" do
248
+ assert_not_nil(Dir::COMMON_DOCUMENTS)
249
+ assert_kind_of(String, Dir::COMMON_DOCUMENTS)
250
+ end
251
+
252
+ test "common_favorites constant is set" do
253
+ assert_not_nil(Dir::COMMON_FAVORITES)
254
+ assert_kind_of(String, Dir::COMMON_FAVORITES)
255
+ end
256
+
257
+ test "common_music constant is set" do
258
+ assert_not_nil(Dir::COMMON_MUSIC)
259
+ assert_kind_of(String, Dir::COMMON_MUSIC)
260
+ end
261
+
262
+ test "common_pictures constant is set" do
263
+ assert_not_nil(Dir::COMMON_PICTURES)
264
+ assert_kind_of(String, Dir::COMMON_PICTURES)
265
+ end
266
+
267
+ test "common_programs constant is set" do
268
+ assert_not_nil(Dir::COMMON_PROGRAMS)
269
+ assert_kind_of(String, Dir::COMMON_PROGRAMS)
270
+ end
271
+
272
+ test "common_startmenu constant is set" do
273
+ assert_not_nil(Dir::COMMON_STARTMENU)
274
+ assert_kind_of(String, Dir::COMMON_STARTMENU)
275
+ end
276
+
277
+ test "common_startup constant is set" do
278
+ assert_not_nil(Dir::COMMON_STARTUP)
279
+ assert_kind_of(String, Dir::COMMON_STARTUP)
280
+ end
281
+
282
+ test "common_templates constant is set" do
283
+ assert_not_nil(Dir::COMMON_TEMPLATES)
284
+ assert_kind_of(String, Dir::COMMON_TEMPLATES)
285
+ end
286
+
287
+ test "common_video constant is set" do
288
+ assert_not_nil(Dir::COMMON_VIDEO)
289
+ assert_kind_of(String, Dir::COMMON_VIDEO)
290
+ end
291
+
292
+ test "controls constant is set" do
293
+ assert_not_nil(Dir::CONTROLS)
294
+ assert_kind_of(String, Dir::CONTROLS)
295
+ end
296
+
297
+ test "cookies constant is set" do
298
+ assert_not_nil(Dir::COOKIES)
299
+ assert_kind_of(String, Dir::COOKIES)
300
+ end
301
+
302
+ test "desktop constant is set" do
303
+ assert_not_nil(Dir::DESKTOP)
304
+ assert_kind_of(String, Dir::DESKTOP)
305
+ end
306
+
307
+ test "desktopdirectory is set" do
308
+ assert_not_nil(Dir::DESKTOPDIRECTORY)
309
+ assert_kind_of(String, Dir::DESKTOPDIRECTORY)
310
+ end
311
+
312
+ test "drives constant is set" do
313
+ assert_not_nil(Dir::DRIVES)
314
+ assert_kind_of(String, Dir::DRIVES)
315
+ end
316
+
317
+ test "favorites constant is set" do
318
+ assert_not_nil(Dir::FAVORITES)
319
+ assert_kind_of(String, Dir::FAVORITES)
320
+ end
321
+
322
+ test "fonts constant is set" do
323
+ assert_not_nil(Dir::FONTS)
324
+ assert_kind_of(String, Dir::FONTS)
325
+ end
326
+
327
+ test "history constant is set" do
328
+ assert_not_nil(Dir::HISTORY)
329
+ assert_kind_of(String, Dir::HISTORY)
330
+ end
331
+
332
+ test "internet constant is set" do
333
+ assert_not_nil(Dir::INTERNET)
334
+ assert_kind_of(String, Dir::INTERNET)
335
+ end
336
+
337
+ test "internet_cache constant is set" do
338
+ assert_not_nil(Dir::INTERNET_CACHE)
339
+ assert_kind_of(String, Dir::INTERNET_CACHE)
340
+ end
341
+
342
+ test "local_appdata constant is set" do
343
+ assert_not_nil(Dir::LOCAL_APPDATA)
344
+ assert_kind_of(String, Dir::LOCAL_APPDATA)
345
+ end
346
+
347
+ test "mydocuments constant is set" do
348
+ assert_not_nil(Dir::MYDOCUMENTS)
349
+ assert_kind_of(String, Dir::MYDOCUMENTS)
350
+ end
351
+
352
+ test "mymusic constant is set" do
353
+ assert_not_nil(Dir::MYMUSIC)
354
+ assert_kind_of(String, Dir::MYMUSIC)
355
+ end
356
+
357
+ test "mypictures constant is set" do
358
+ assert_not_nil(Dir::MYPICTURES)
359
+ assert_kind_of(String, Dir::MYPICTURES)
360
+ end
361
+
362
+ test "myvideo constant is set" do
363
+ assert_not_nil(Dir::MYVIDEO)
364
+ assert_kind_of(String, Dir::MYVIDEO)
365
+ end
366
+
367
+ test "nethood constant is set" do
368
+ assert_not_nil(Dir::NETHOOD)
369
+ assert_kind_of(String, Dir::NETHOOD)
370
+ end
371
+
372
+ test "network constant is set" do
373
+ assert_not_nil(Dir::NETWORK)
374
+ assert_kind_of(String, Dir::NETWORK)
375
+ end
376
+
377
+ test "personal constant is set" do
378
+ assert_not_nil(Dir::PERSONAL)
379
+ assert_kind_of(String, Dir::PERSONAL)
380
+ end
381
+
382
+ test "printers cosntant is set" do
383
+ assert_not_nil(Dir::PRINTERS)
384
+ assert_kind_of(String, Dir::PRINTERS)
385
+ end
386
+
387
+ test "printhood constant is set" do
388
+ assert_not_nil(Dir::PRINTHOOD)
389
+ assert_kind_of(String, Dir::PRINTHOOD)
390
+ end
391
+
392
+ test "profile constant is set" do
393
+ assert_not_nil(Dir::PROFILE)
394
+ assert_kind_of(String, Dir::PROFILE)
395
+ end
396
+
397
+ test "program_files constant is set" do
398
+ assert_not_nil(Dir::PROGRAM_FILES)
399
+ assert_kind_of(String, Dir::PROGRAM_FILES)
400
+ end
401
+
402
+ test "program_files_common constant is set" do
403
+ assert_not_nil(Dir::PROGRAM_FILES_COMMON)
404
+ assert_kind_of(String, Dir::PROGRAM_FILES_COMMON)
405
+ end
406
+
407
+ test "programs constant is set" do
408
+ assert_not_nil(Dir::PROGRAMS)
409
+ assert_kind_of(String, Dir::PROGRAMS)
410
+ end
411
+
412
+ test "recent constant is set" do
413
+ assert_not_nil(Dir::RECENT)
414
+ assert_kind_of(String, Dir::RECENT)
415
+ end
416
+
417
+ test "sendto constant is set" do
418
+ assert_not_nil(Dir::SENDTO)
419
+ assert_kind_of(String, Dir::SENDTO)
420
+ end
421
+
422
+ test "startmenu constant is set" do
423
+ assert_not_nil(Dir::STARTMENU)
424
+ assert_kind_of(String, Dir::STARTMENU)
425
+ end
426
+
427
+ test "startup constant is set" do
428
+ assert_not_nil(Dir::STARTUP)
429
+ assert_kind_of(String, Dir::STARTUP)
430
+ end
431
+
432
+ test "system constant is set" do
433
+ assert_not_nil(Dir::SYSTEM)
434
+ assert_kind_of(String, Dir::SYSTEM)
435
+ end
436
+
437
+ test "templates constant is set" do
438
+ assert_not_nil(Dir::TEMPLATES)
439
+ assert_kind_of(String, Dir::TEMPLATES)
440
+ end
441
+
442
+ test "windows constant is set" do
443
+ assert_not_nil(Dir::WINDOWS)
444
+ assert_kind_of(String, Dir::WINDOWS)
445
+ end
446
+
447
+ test "constants are ascii_compatible?" do
448
+ assert_true(Dir::COMMON_APPDATA.encoding.ascii_compatible?)
449
+ assert_nothing_raised{ File.join(Dir::COMMON_APPDATA, 'foo') }
450
+ end
451
+
452
+ test "ffi functions are private" do
453
+ assert_not_respond_to(Dir, :SHGetFolderPathW)
454
+ end
455
+
456
+ def teardown
457
+ FileUtils.rm_rf(@ascii_to)
458
+ FileUtils.rm_rf(@unicode_to)
459
+ end
460
+
461
+ def self.shutdown
462
+ FileUtils.rm_rf(@@from)
463
+ @@test_home = nil
464
+ @@from = nil
465
+ end
466
+ end