win32-dir 0.5.1 → 0.7.2
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.
- checksums.yaml +5 -5
- data/lib/win32-dir.rb +1 -1
- data/lib/win32/dir.rb +418 -417
- data/lib/win32/dir/constants.rb +26 -26
- data/lib/win32/dir/functions.rb +66 -66
- data/lib/win32/dir/structs.rb +37 -37
- data/lib/win32/dir/version.rb +6 -0
- metadata +9 -71
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGES +0 -121
- data/MANIFEST +0 -10
- data/README +0 -273
- data/Rakefile +0 -34
- data/certs/djberg96_pub.pem +0 -21
- data/examples/dir_example.rb +0 -23
- data/test/test_win32_dir.rb +0 -466
- data/win32-dir.gemspec +0 -30
- metadata.gz.sig +0 -2
data/MANIFEST
DELETED
data/README
DELETED
@@ -1,273 +0,0 @@
|
|
1
|
-
= Description
|
2
|
-
A series of extra constants for the Dir class that define special folders
|
3
|
-
on MS Windows systems, as well as methods for creating and detecting
|
4
|
-
junctions, i.e. symlinks for directories.
|
5
|
-
|
6
|
-
= Installation
|
7
|
-
gem install win32-dir
|
8
|
-
|
9
|
-
= Synopsis
|
10
|
-
require 'win32/dir'
|
11
|
-
|
12
|
-
# C:\WINNT or C:\WINDOWS
|
13
|
-
puts Dir::WINDOWS
|
14
|
-
|
15
|
-
# C:\Documents and Settings\Daniel\Start Menu\Programs\Administrative Tools
|
16
|
-
puts Dir::ADMINTOOLS
|
17
|
-
|
18
|
-
Dir.mkdir('C:\from')
|
19
|
-
Dir.create_junction('C:\to', 'C:\from')
|
20
|
-
|
21
|
-
= Constants
|
22
|
-
Not all of these are guaranteed to be defined on your system. Also note
|
23
|
-
that the directories are merely defined. It doesn't necessarily mean they
|
24
|
-
actually exist.
|
25
|
-
|
26
|
-
== The following constants should be defined:
|
27
|
-
Dir::ADMINTOOLS
|
28
|
-
The file system directory that is used to store administrative tools for an
|
29
|
-
individual user. The Microsoft Management Console (MMC) will save
|
30
|
-
customized consoles to this directory, and it will roam with the user.
|
31
|
-
|
32
|
-
Dir::COMMON_ADMINTOOLS
|
33
|
-
The file system directory containing administrative tools for all users
|
34
|
-
of the computer.
|
35
|
-
|
36
|
-
Dir::APPDATA
|
37
|
-
The file system directory that serves as a common repository for
|
38
|
-
application-specific data. A typical path is
|
39
|
-
C:\Documents and Settings\<user>\Application Data.
|
40
|
-
|
41
|
-
This CSIDL is supported by the redistributable shfolder.dll for
|
42
|
-
systems that do not have the Microsoft Internet Explorer 4.0
|
43
|
-
integrated Shell installed.
|
44
|
-
|
45
|
-
Dir::COMMON_APPDATA
|
46
|
-
The file system directory containing application data for all users. A
|
47
|
-
typical path is C:\Documents and Settings\All Users\Application Data.
|
48
|
-
|
49
|
-
Dir::COMMON_DOCUMENTS
|
50
|
-
The file system directory that contains documents that are common to all
|
51
|
-
users. A typical paths is C:\Documents and Settings\All Users\Documents.
|
52
|
-
|
53
|
-
Dir::COOKIES
|
54
|
-
The file system directory that serves as a common repository for Internet
|
55
|
-
cookies. A typical path is C:\Documents and Settings\<user>\Cookies.
|
56
|
-
|
57
|
-
Dir::HISTORY
|
58
|
-
The file system directory that serves as a common repository for Internet
|
59
|
-
history items.
|
60
|
-
|
61
|
-
Dir::INTERNET_CACHE
|
62
|
-
The file system directory that serves as a common repository for temporary
|
63
|
-
Internet files. A typical path is
|
64
|
-
C:\Documents and Settings\<user>\Local Settings\Temporary Internet Files.
|
65
|
-
|
66
|
-
Dir::LOCAL_APPDATA
|
67
|
-
The file system directory that serves as a data repository for local
|
68
|
-
(nonroaming) applications. A typical path is
|
69
|
-
C:\Documents and Settings\<user>\Local Settings\Application Data.
|
70
|
-
|
71
|
-
Dir::MYPICTURES
|
72
|
-
The file system directory that serves as a common repository for image
|
73
|
-
files. A typical path is
|
74
|
-
C:\Documents and Settings\<user>\My Documents\My Pictures.
|
75
|
-
|
76
|
-
Dir::PERSONAL
|
77
|
-
The virtual folder representing the My Documents desktop item. This is
|
78
|
-
equivalent to Dir::MYDOCUMENTS.
|
79
|
-
|
80
|
-
Dir::PROGRAM_FILES
|
81
|
-
The Program Files folder. A typical path is C:\Program Files.
|
82
|
-
|
83
|
-
Dir::PROGRAM_FILES_COMMON
|
84
|
-
A folder for components that are shared across applications. A typical path
|
85
|
-
is C:\Program Files\Common.
|
86
|
-
|
87
|
-
Dir::SYSTEM
|
88
|
-
The Windows System folder. A typical path is C:\Windows\System32.
|
89
|
-
|
90
|
-
Dir::WINDOWS
|
91
|
-
The Windows directory or SYSROOT. This corresponds to the %windir% or
|
92
|
-
%SYSTEMROOT% environment variables. A typical path is C:\Windows.
|
93
|
-
|
94
|
-
== The following constants may or may not be defined:
|
95
|
-
Dir::ALTSTARTUP
|
96
|
-
The file system directory that corresponds to the user's nonlocalized
|
97
|
-
Startup program group.
|
98
|
-
|
99
|
-
Dir::BITBUCKET
|
100
|
-
The virtual folder containing the objects in the user's Recycle Bin.
|
101
|
-
|
102
|
-
Dir::CDBURN_AREA
|
103
|
-
The file system directory acting as a staging area for files waiting to
|
104
|
-
be written to CD.
|
105
|
-
|
106
|
-
Dir::COMMON_ALTSTARTUP
|
107
|
-
The file system directory that corresponds to the nonlocalized Startup
|
108
|
-
program group for all users.
|
109
|
-
|
110
|
-
Dir::COMMON_DESKTOPDIRECTORY
|
111
|
-
The file system directory that contains files and folders that appear on
|
112
|
-
the desktop for all users. A typical path is
|
113
|
-
C:\Documents and Settings\All Users\Desktop.
|
114
|
-
|
115
|
-
Dir::COMMON_FAVORITES
|
116
|
-
The file system directory that serves as a common repository for favorite
|
117
|
-
items common to all users.
|
118
|
-
|
119
|
-
Dir::COMMON_MUSIC
|
120
|
-
The file system directory that serves as a repository for music files
|
121
|
-
common to all users.
|
122
|
-
|
123
|
-
Dir::COMMON_PICTURES
|
124
|
-
The file system directory that serves as a repository for image files
|
125
|
-
common to all users.
|
126
|
-
|
127
|
-
Dir::COMMON_PROGRAMS
|
128
|
-
The file system directory that contains the directories for the common
|
129
|
-
program groups that appear on the Start menu for all users.
|
130
|
-
|
131
|
-
Dir::COMMON_STARTMENU
|
132
|
-
The file system directory that contains the programs and folders that
|
133
|
-
appear on the Start menu for all users.
|
134
|
-
|
135
|
-
Dir::COMMON_STARTUP
|
136
|
-
The file system directory that contains the programs that appear in the
|
137
|
-
Startup folder for all users.
|
138
|
-
|
139
|
-
Dir::COMMON_TEMPLATES
|
140
|
-
The file system directory that contains the templates that are available
|
141
|
-
to all users.
|
142
|
-
|
143
|
-
Dir::COMMON_VIDEO
|
144
|
-
The file system directory that serves as a repository for video files
|
145
|
-
common to all users.
|
146
|
-
|
147
|
-
Dir::CONTROLS
|
148
|
-
The virtual folder containing icons for the Control Panel applications.
|
149
|
-
|
150
|
-
Dir::DESKTOP
|
151
|
-
The virtual folder representing the Windows desktop, the root of the
|
152
|
-
namespace.
|
153
|
-
|
154
|
-
Dir::DESKTOPDIRECTORY
|
155
|
-
The file system directory used to physically store file objects on the
|
156
|
-
desktop (not to be confused with the desktop folder itself).
|
157
|
-
|
158
|
-
Dir::DRIVES
|
159
|
-
The virtual folder representing My Computer, containing everything on
|
160
|
-
the local computer: storage devices, printers, and Control Panel. The
|
161
|
-
folder may also contain mapped network drives.
|
162
|
-
|
163
|
-
Dir::FAVORITES
|
164
|
-
The file system directory that serves as a common repository for the
|
165
|
-
user's favorite items.
|
166
|
-
|
167
|
-
Dir::FONTS
|
168
|
-
A virtual folder containing fonts.
|
169
|
-
|
170
|
-
Dir::INTERNET
|
171
|
-
A virtual folder representing the Internet.
|
172
|
-
|
173
|
-
Dir::MYDOCUMENTS
|
174
|
-
The virtual folder representing the My Documents desktop item. See also
|
175
|
-
Dir::PERSONAL.
|
176
|
-
|
177
|
-
Dir::MYMUSIC
|
178
|
-
The file system directory that serves as a common repository for music files.
|
179
|
-
|
180
|
-
Dir::MYVIDEO
|
181
|
-
The file system directory that serves as a common repository for video files.
|
182
|
-
|
183
|
-
Dir::NETHOOD
|
184
|
-
A file system directory containing the link objects that may exist in the
|
185
|
-
My Network Places virtual folder. It is not the same as Dir::NETWORK, which
|
186
|
-
represents the network namespace root.
|
187
|
-
|
188
|
-
Dir::NETWORK
|
189
|
-
A virtual folder representing Network Neighborhood, the root of the network
|
190
|
-
namespace hierarchy.
|
191
|
-
|
192
|
-
Dir::PRINTERS
|
193
|
-
The virtual folder containing installed printers.
|
194
|
-
|
195
|
-
Dir::PRINTHOOD
|
196
|
-
The file system directory that contains the link objects that can exist in
|
197
|
-
the "Printers" virtual folder.
|
198
|
-
|
199
|
-
Dir::PROFILE
|
200
|
-
The user's profile folder.
|
201
|
-
|
202
|
-
Dir::PROFILES
|
203
|
-
The file system directory containing user profile folders.
|
204
|
-
|
205
|
-
Dir::PROGRAMS
|
206
|
-
The file system directory that contains the user's program groups (which
|
207
|
-
are themselves file system directories).
|
208
|
-
|
209
|
-
Dir::RECENT
|
210
|
-
The file system directory that contains shortcuts to the user's most
|
211
|
-
recently used documents.
|
212
|
-
|
213
|
-
Dir::SENDTO
|
214
|
-
The file system directory that contains Send To menu items.
|
215
|
-
|
216
|
-
Dir::STARTMENU
|
217
|
-
The file system directory containing Start menu items.
|
218
|
-
|
219
|
-
Dir::STARTUP
|
220
|
-
The file system directory that corresponds to the user's Startup program
|
221
|
-
group.
|
222
|
-
|
223
|
-
Dir::TEMPLATES
|
224
|
-
The file system directory that serves as a common repository for document
|
225
|
-
templates.
|
226
|
-
|
227
|
-
== Developer's Notes
|
228
|
-
The SHGetFolderPath() documentation on MSDN is somewhat vague about which
|
229
|
-
CSIDL constants are guaranteed to be defined. However, there are 15 which
|
230
|
-
*should* be defined (see docs above). The rest I cannot vouch for.
|
231
|
-
|
232
|
-
Some of these folders are virtual, and the value will be the display name
|
233
|
-
only instead of an actual path.
|
234
|
-
|
235
|
-
== Known Bugs
|
236
|
-
The Dir.create_junction and Dir.read_junction methods do not work with JRuby.
|
237
|
-
|
238
|
-
Please log any bug reports on the project page at
|
239
|
-
http://www.github.com/djberg96/win32-dir
|
240
|
-
|
241
|
-
== Future Plans
|
242
|
-
Suggestions welcome.
|
243
|
-
|
244
|
-
== Acknowledgements
|
245
|
-
Shashank Date and Zach Dennis for the suggestion and supporting comments
|
246
|
-
on the mailing list.
|
247
|
-
|
248
|
-
Timothy Byrd and Autrijus Tang for help (directly or indirectly) with the
|
249
|
-
junction methods. Timothy provided a pure Ruby version of the junction
|
250
|
-
code that I later borrowed from.
|
251
|
-
|
252
|
-
Most of the documentation was copied from the MSDN web site.
|
253
|
-
|
254
|
-
== License
|
255
|
-
Artistic 2.0
|
256
|
-
|
257
|
-
== Contributions
|
258
|
-
Although this library is free, please consider having your company
|
259
|
-
setup a gittip if used by your company professionally.
|
260
|
-
|
261
|
-
http://www.gittip.com/djberg96/
|
262
|
-
|
263
|
-
== Copyright
|
264
|
-
(C) 2003-2015 Daniel J. Berger, All Rights Reserved
|
265
|
-
|
266
|
-
== Warranty
|
267
|
-
This package is provided "as is" and without any express or
|
268
|
-
implied warranties, including, without limitation, the implied
|
269
|
-
warranties of merchantability and fitness for a particular purpose.
|
270
|
-
|
271
|
-
== Authors
|
272
|
-
Daniel J. Berger
|
273
|
-
Park Heesob
|
data/Rakefile
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'rake/clean'
|
3
|
-
require 'rake/testtask'
|
4
|
-
|
5
|
-
CLEAN.include('**/*.gem', '**/*.log')
|
6
|
-
|
7
|
-
namespace 'gem' do
|
8
|
-
desc "Create the win32-dir gem"
|
9
|
-
task :create => [:clean] do
|
10
|
-
require 'rubygems/package'
|
11
|
-
Dir["*.gem"].each{ |f| File.delete(f) }
|
12
|
-
spec = eval(IO.read('win32-dir.gemspec'))
|
13
|
-
spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
|
14
|
-
Gem::Package.build(spec)
|
15
|
-
end
|
16
|
-
|
17
|
-
desc "Install the win32-dir gem"
|
18
|
-
task :install => [:create] do
|
19
|
-
file = Dir["*.gem"].first
|
20
|
-
sh "gem install -l #{file}"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
desc "Run the example program"
|
25
|
-
task :example do
|
26
|
-
sh "ruby -Ilib examples/dir_example.rb"
|
27
|
-
end
|
28
|
-
|
29
|
-
Rake::TestTask.new do |t|
|
30
|
-
t.warning = true
|
31
|
-
t.verbose = true
|
32
|
-
end
|
33
|
-
|
34
|
-
task :default => :test
|
data/certs/djberg96_pub.pem
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
-----BEGIN CERTIFICATE-----
|
2
|
-
MIIDcDCCAligAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MREwDwYDVQQDDAhkamJl
|
3
|
-
cmc5NjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
|
4
|
-
MB4XDTE1MDkwMjIwNDkxOFoXDTE2MDkwMTIwNDkxOFowPzERMA8GA1UEAwwIZGpi
|
5
|
-
ZXJnOTYxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
|
6
|
-
bTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMyTkvXqRp6hLs9eoJOS
|
7
|
-
Hmi8kRYbq9Vkf15/hMxJpotYMgJVHHWrmDcC5Dye2PbnXjTkKf266Zw0PtT9h+lI
|
8
|
-
S3ts9HO+vaCFSMwFFZmnWJSpQ3CNw2RcHxjWkk9yF7imEM8Kz9ojhiDXzBetdV6M
|
9
|
-
gr0lV/alUr7TNVBDngbXEfTWscyXh1qd7xZ4EcOdsDktCe5G45N/o3662tPQvJsi
|
10
|
-
FOF0CM/KuBsa/HL1/eoEmF4B3EKIRfTHrQ3hu20Kv3RJ88QM4ec2+0dd97uX693O
|
11
|
-
zv6981fyEg+aXLkxrkViM/tz2qR2ZE0jPhHTREPYeMEgptRkTmWSKAuLVWrJEfgl
|
12
|
-
DtkCAwEAAaN3MHUwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFEwe
|
13
|
-
nn6bfJADmuIDiMSOzedOrL+xMB0GA1UdEQQWMBSBEmRqYmVyZzk2QGdtYWlsLmNv
|
14
|
-
bTAdBgNVHRIEFjAUgRJkamJlcmc5NkBnbWFpbC5jb20wDQYJKoZIhvcNAQEFBQAD
|
15
|
-
ggEBAHmNOCWoDVD75zHFueY0viwGDVP1BNGFC+yXcb7u2GlK+nEMCORqzURbYPf7
|
16
|
-
tL+/hzmePIRz7i30UM//64GI1NLv9jl7nIwjhPpXpf7/lu2I9hOTsvwSumb5UiKC
|
17
|
-
/sqBxI3sfj9pr79Wpv4MuikX1XPik7Ncb7NPsJPw06Lvyc3Hkg5X2XpPtLtS+Gr2
|
18
|
-
wKJnmzb5rIPS1cmsqv0M9LPWflzfwoZ/SpnmhagP+g05p8bRNKjZSA2iImM/GyYZ
|
19
|
-
EJYzxdPOrx2n6NYR3Hk+vHP0U7UBSveI6+qx+ndQYaeyCn+GRX2PKS9h66YF/Q1V
|
20
|
-
tGSHgAmcLlkdGgan182qsE/4kKM=
|
21
|
-
-----END CERTIFICATE-----
|
data/examples/dir_example.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
####################################################################
|
2
|
-
# dir_example.rb
|
3
|
-
#
|
4
|
-
# Generic test script for general futzing. Modify as you see fit.
|
5
|
-
# You can run this via the 'rake example' task.
|
6
|
-
####################################################################
|
7
|
-
require 'win32/dir'
|
8
|
-
|
9
|
-
puts "Admin Tools:\t\t" + Dir::ADMINTOOLS
|
10
|
-
puts "Common Admin Tools:\t" + Dir::COMMON_ADMINTOOLS
|
11
|
-
puts "App Data:\t\t" + Dir::APPDATA
|
12
|
-
puts "Common App Data:\t" + Dir::COMMON_APPDATA
|
13
|
-
puts "Common Documents:\t" + Dir::COMMON_DOCUMENTS
|
14
|
-
puts "Cookies:\t\t" + Dir::COOKIES
|
15
|
-
puts "History:\t\t" + Dir::HISTORY
|
16
|
-
puts "Internet Cache:\t\t" + Dir::INTERNET_CACHE
|
17
|
-
puts "Local App Data:\t\t" + Dir::LOCAL_APPDATA
|
18
|
-
puts "My Pictures:\t\t" + Dir::MYPICTURES
|
19
|
-
puts "Personal:\t\t" + Dir::PERSONAL
|
20
|
-
puts "Program Files:\t\t" + Dir::PROGRAM_FILES
|
21
|
-
puts "Program Files Common:\t" + Dir::PROGRAM_FILES_COMMON
|
22
|
-
puts "System:\t\t\t" + Dir::SYSTEM
|
23
|
-
puts "Windows:\t\t" + Dir::WINDOWS
|
data/test/test_win32_dir.rb
DELETED
@@ -1,466 +0,0 @@
|
|
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
|