win32-dir 0.3.5 → 0.3.6
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.
- data/CHANGES +8 -1
- data/MANIFEST +1 -1
- data/README +138 -141
- data/Rakefile +20 -11
- data/lib/win32/dir.rb +176 -171
- data/test/test_win32_dir.rb +356 -0
- data/win32-dir.gemspec +22 -24
- metadata +8 -8
- data/test/test_dir.rb +0 -353
data/CHANGES
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
== 0.3.6 - 6-Feb-2010
|
2
|
+
* Bug fixes for Ruby 1.9.x. Thanks go to Kendall Gifford for the spot and
|
3
|
+
the patch.
|
4
|
+
* Minor refactoring of the Dir.create_junction method. This fixed a bug for
|
5
|
+
Ruby 1.9.x, but was also a little cleaner in general.
|
6
|
+
* Some Rakefile task and gemspec updates.
|
7
|
+
|
1
8
|
== 0.3.5 - 6-Aug-2009
|
2
9
|
* Changed the license to Artistic 2.0.
|
3
10
|
* Updated the gemspec, including the addition of a license attribute and
|
@@ -38,4 +45,4 @@
|
|
38
45
|
* Added corresponding tests and documentation.
|
39
46
|
|
40
47
|
== 0.1.0 - 25-Feb-2005
|
41
|
-
* Initial release
|
48
|
+
* Initial release
|
data/MANIFEST
CHANGED
data/README
CHANGED
@@ -1,273 +1,270 @@
|
|
1
1
|
= Description
|
2
|
-
|
3
|
-
|
4
|
-
|
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
5
|
|
6
6
|
= Installation
|
7
|
-
|
8
|
-
rake install (non-gem) or rake install_gem (gem).
|
7
|
+
gem install win32-dir
|
9
8
|
|
10
9
|
= Synopsis
|
11
|
-
|
10
|
+
require 'win32/dir'
|
12
11
|
|
13
|
-
|
14
|
-
|
12
|
+
# C:\WINNT or C:\WINDOWS
|
13
|
+
puts Dir::WINDOWS
|
15
14
|
|
16
|
-
|
17
|
-
|
15
|
+
# C:\Documents and Settings\Daniel\Start Menu\Programs\Administrative Tools
|
16
|
+
puts Dir::ADMINTOOLS
|
18
17
|
|
19
|
-
|
20
|
-
|
18
|
+
Dir.mkdir('C:\from')
|
19
|
+
Dir.create_junction('C:\to', 'C:\from')
|
21
20
|
|
22
21
|
= Constants
|
23
|
-
|
24
|
-
|
25
|
-
|
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.
|
26
25
|
|
27
26
|
== The following constants should be defined:
|
28
27
|
Dir::ADMINTOOLS
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
+
|
33
32
|
Dir::COMMON_ADMINTOOLS
|
34
|
-
|
35
|
-
|
33
|
+
The file system directory containing administrative tools for all users
|
34
|
+
of the computer.
|
36
35
|
|
37
36
|
Dir::APPDATA
|
38
|
-
|
39
|
-
|
40
|
-
|
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.
|
41
40
|
|
42
|
-
|
43
|
-
|
44
|
-
|
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.
|
45
44
|
|
46
45
|
Dir::COMMON_APPDATA
|
47
|
-
|
48
|
-
|
46
|
+
The file system directory containing application data for all users. A
|
47
|
+
typical path is C:\Documents and Settings\All Users\Application Data.
|
49
48
|
|
50
49
|
Dir::COMMON_DOCUMENTS
|
51
|
-
|
52
|
-
|
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.
|
53
52
|
|
54
53
|
Dir::COOKIES
|
55
|
-
|
56
|
-
|
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.
|
57
56
|
|
58
57
|
Dir::HISTORY
|
59
|
-
|
60
|
-
|
58
|
+
The file system directory that serves as a common repository for Internet
|
59
|
+
history items.
|
61
60
|
|
62
61
|
Dir::INTERNET_CACHE
|
63
|
-
|
64
|
-
|
65
|
-
|
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.
|
66
65
|
|
67
66
|
Dir::LOCAL_APPDATA
|
68
|
-
|
69
|
-
|
70
|
-
|
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.
|
71
70
|
|
72
71
|
Dir::MYPICTURES
|
73
|
-
|
74
|
-
|
75
|
-
|
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.
|
76
75
|
|
77
76
|
Dir::PERSONAL
|
78
|
-
|
79
|
-
|
77
|
+
The virtual folder representing the My Documents desktop item. This is
|
78
|
+
equivalent to Dir::MYDOCUMENTS.
|
80
79
|
|
81
80
|
Dir::PROGRAM_FILES
|
82
|
-
|
81
|
+
The Program Files folder. A typical path is C:\Program Files.
|
83
82
|
|
84
83
|
Dir::PROGRAM_FILES_COMMON
|
85
|
-
|
86
|
-
|
84
|
+
A folder for components that are shared across applications. A typical path
|
85
|
+
is C:\Program Files\Common.
|
87
86
|
|
88
87
|
Dir::SYSTEM
|
89
|
-
|
88
|
+
The Windows System folder. A typical path is C:\Windows\System32.
|
90
89
|
|
91
90
|
Dir::WINDOWS
|
92
|
-
|
93
|
-
|
91
|
+
The Windows directory or SYSROOT. This corresponds to the %windir% or
|
92
|
+
%SYSTEMROOT% environment variables. A typical path is C:\Windows.
|
94
93
|
|
95
94
|
== The following constants may or may not be defined:
|
96
95
|
Dir::ALTSTARTUP
|
97
|
-
|
98
|
-
|
96
|
+
The file system directory that corresponds to the user's nonlocalized
|
97
|
+
Startup program group.
|
99
98
|
|
100
99
|
Dir::BITBUCKET
|
101
|
-
|
100
|
+
The virtual folder containing the objects in the user's Recycle Bin.
|
102
101
|
|
103
102
|
Dir::CDBURN_AREA
|
104
|
-
|
105
|
-
|
103
|
+
The file system directory acting as a staging area for files waiting to
|
104
|
+
be written to CD.
|
106
105
|
|
107
106
|
Dir::COMMON_ALTSTARTUP
|
108
|
-
|
109
|
-
|
107
|
+
The file system directory that corresponds to the nonlocalized Startup
|
108
|
+
program group for all users.
|
110
109
|
|
111
110
|
Dir::COMMON_DESKTOPDIRECTORY
|
112
|
-
|
113
|
-
|
114
|
-
|
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.
|
115
114
|
|
116
115
|
Dir::COMMON_FAVORITES
|
117
|
-
|
118
|
-
|
116
|
+
The file system directory that serves as a common repository for favorite
|
117
|
+
items common to all users.
|
119
118
|
|
120
119
|
Dir::COMMON_MUSIC
|
121
|
-
|
122
|
-
|
120
|
+
The file system directory that serves as a repository for music files
|
121
|
+
common to all users.
|
123
122
|
|
124
123
|
Dir::COMMON_PICTURES
|
125
|
-
|
126
|
-
|
124
|
+
The file system directory that serves as a repository for image files
|
125
|
+
common to all users.
|
127
126
|
|
128
127
|
Dir::COMMON_PROGRAMS
|
129
|
-
|
130
|
-
|
128
|
+
The file system directory that contains the directories for the common
|
129
|
+
program groups that appear on the Start menu for all users.
|
131
130
|
|
132
131
|
Dir::COMMON_STARTMENU
|
133
|
-
|
134
|
-
|
132
|
+
The file system directory that contains the programs and folders that
|
133
|
+
appear on the Start menu for all users.
|
135
134
|
|
136
135
|
Dir::COMMON_STARTUP
|
137
|
-
|
138
|
-
|
136
|
+
The file system directory that contains the programs that appear in the
|
137
|
+
Startup folder for all users.
|
139
138
|
|
140
139
|
Dir::COMMON_TEMPLATES
|
141
|
-
|
142
|
-
|
140
|
+
The file system directory that contains the templates that are available
|
141
|
+
to all users.
|
143
142
|
|
144
143
|
Dir::COMMON_VIDEO
|
145
|
-
|
146
|
-
|
144
|
+
The file system directory that serves as a repository for video files
|
145
|
+
common to all users.
|
147
146
|
|
148
147
|
Dir::CONTROLS
|
149
|
-
|
148
|
+
The virtual folder containing icons for the Control Panel applications.
|
150
149
|
|
151
150
|
Dir::DESKTOP
|
152
|
-
|
153
|
-
|
151
|
+
The virtual folder representing the Windows desktop, the root of the
|
152
|
+
namespace.
|
154
153
|
|
155
154
|
Dir::DESKTOPDIRECTORY
|
156
|
-
|
157
|
-
|
155
|
+
The file system directory used to physically store file objects on the
|
156
|
+
desktop (not to be confused with the desktop folder itself).
|
158
157
|
|
159
158
|
Dir::DRIVES
|
160
|
-
|
161
|
-
|
162
|
-
|
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.
|
163
162
|
|
164
163
|
Dir::FAVORITES
|
165
|
-
|
166
|
-
|
164
|
+
The file system directory that serves as a common repository for the
|
165
|
+
user's favorite items.
|
167
166
|
|
168
167
|
Dir::FONTS
|
169
|
-
|
168
|
+
A virtual folder containing fonts.
|
170
169
|
|
171
170
|
Dir::INTERNET
|
172
|
-
|
171
|
+
A virtual folder representing the Internet.
|
173
172
|
|
174
173
|
Dir::MYDOCUMENTS
|
175
|
-
|
176
|
-
|
174
|
+
The virtual folder representing the My Documents desktop item. See also
|
175
|
+
Dir::PERSONAL.
|
177
176
|
|
178
177
|
Dir::MYMUSIC
|
179
|
-
|
180
|
-
files.
|
178
|
+
The file system directory that serves as a common repository for music files.
|
181
179
|
|
182
180
|
Dir::MYVIDEO
|
183
|
-
|
184
|
-
files.
|
181
|
+
The file system directory that serves as a common repository for video files.
|
185
182
|
|
186
183
|
Dir::NETHOOD
|
187
|
-
|
188
|
-
|
189
|
-
|
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.
|
190
187
|
|
191
188
|
Dir::NETWORK
|
192
|
-
|
193
|
-
|
189
|
+
A virtual folder representing Network Neighborhood, the root of the network
|
190
|
+
namespace hierarchy.
|
194
191
|
|
195
192
|
Dir::PRINTERS
|
196
|
-
|
193
|
+
The virtual folder containing installed printers.
|
197
194
|
|
198
195
|
Dir::PRINTHOOD
|
199
|
-
|
200
|
-
|
196
|
+
The file system directory that contains the link objects that can exist in
|
197
|
+
the "Printers" virtual folder.
|
201
198
|
|
202
199
|
Dir::PROFILE
|
203
|
-
|
200
|
+
The user's profile folder.
|
204
201
|
|
205
202
|
Dir::PROFILES
|
206
|
-
|
203
|
+
The file system directory containing user profile folders.
|
207
204
|
|
208
205
|
Dir::PROGRAMS
|
209
|
-
|
210
|
-
|
206
|
+
The file system directory that contains the user's program groups (which
|
207
|
+
are themselves file system directories).
|
211
208
|
|
212
209
|
Dir::RECENT
|
213
|
-
|
214
|
-
|
210
|
+
The file system directory that contains shortcuts to the user's most
|
211
|
+
recently used documents.
|
215
212
|
|
216
213
|
Dir::SENDTO
|
217
|
-
|
214
|
+
The file system directory that contains Send To menu items.
|
218
215
|
|
219
216
|
Dir::STARTMENU
|
220
|
-
|
217
|
+
The file system directory containing Start menu items.
|
221
218
|
|
222
219
|
Dir::STARTUP
|
223
|
-
|
224
|
-
|
220
|
+
The file system directory that corresponds to the user's Startup program
|
221
|
+
group.
|
225
222
|
|
226
223
|
Dir::TEMPLATES
|
227
|
-
|
228
|
-
|
224
|
+
The file system directory that serves as a common repository for document
|
225
|
+
templates.
|
229
226
|
|
230
227
|
== Developer's Notes
|
231
|
-
|
232
|
-
|
233
|
-
|
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.
|
234
231
|
|
235
|
-
|
236
|
-
|
232
|
+
Some of these folders are virtual, and the value will be the display name
|
233
|
+
only instead of an actual path.
|
237
234
|
|
238
235
|
== Known Bugs
|
239
|
-
|
240
|
-
|
241
|
-
|
236
|
+
The Unicode support is not quite there for Dir.create_junction. It creates
|
237
|
+
the directory and junction fine, but the +to+ name appears to get garbled
|
238
|
+
with regards to the character set.
|
242
239
|
|
243
|
-
|
244
|
-
|
240
|
+
Please log any other bug reports on the RubyForge project page at
|
241
|
+
http://www.rubyforge.net/projects/win32utils.
|
245
242
|
|
246
243
|
== Future Plans
|
247
|
-
|
248
|
-
|
244
|
+
Fix the Unicode issue with Dir.create_junction.
|
245
|
+
Other suggestions welcome.
|
249
246
|
|
250
247
|
== Acknowledgements
|
251
|
-
|
252
|
-
|
248
|
+
Shashank Date and Zach Dennis for the suggestion and supporting comments
|
249
|
+
on the mailing list.
|
253
250
|
|
254
|
-
|
255
|
-
|
256
|
-
|
251
|
+
Timothy Byrd and Autrijus Tang for help (directly or indirectly) with the
|
252
|
+
junction methods. Timothy provided a pure Ruby version of the junction
|
253
|
+
code that I later borrowed from.
|
257
254
|
|
258
|
-
|
255
|
+
Most of the documentation was copied from the MSDN web site.
|
259
256
|
|
260
257
|
== License
|
261
|
-
|
258
|
+
Artistic 2.0
|
262
259
|
|
263
260
|
== Copyright
|
264
|
-
|
261
|
+
(C) 2003-2010 Daniel J. Berger, All Rights Reserved
|
265
262
|
|
266
263
|
== Warranty
|
267
|
-
|
268
|
-
|
269
|
-
|
264
|
+
This package is provided "as is" and without any express or
|
265
|
+
implied warranties, including, without limitation, the implied
|
266
|
+
warranties of merchantability and fitness for a particular purpose.
|
270
267
|
|
271
268
|
== Authors
|
272
|
-
|
273
|
-
|
269
|
+
Daniel J. Berger
|
270
|
+
Park Heesob
|
data/Rakefile
CHANGED
@@ -3,23 +3,32 @@ require 'rake/testtask'
|
|
3
3
|
|
4
4
|
desc "Install the win32-dir package (non-gem)"
|
5
5
|
task :install do
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
dest = File.join(Config::CONFIG['sitelibdir'], 'win32')
|
7
|
+
Dir.mkdir(dest) unless File.exists? dest
|
8
|
+
cp 'lib/win32/dir.rb', dest, :verbose => true
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
namespace 'gem' do
|
12
|
+
desc "Build the gem"
|
13
|
+
task :build do
|
14
|
+
Dir["*.gem"].each{ |f| File.delete(f) }
|
15
|
+
spec = eval(IO.read('win32-dir.gemspec'))
|
16
|
+
Gem::Builder.new(spec).build
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "Install the win32-dir package as a gem"
|
20
|
+
task :install => [:build] do
|
21
|
+
file = Dir["*.gem"].first
|
22
|
+
sh "gem install #{file}"
|
23
|
+
end
|
16
24
|
end
|
17
25
|
|
18
26
|
desc "Run the example program"
|
19
27
|
task :example do
|
20
|
-
|
28
|
+
sh "ruby -Ilib examples/dir_example.rb"
|
29
|
+
end
|
21
30
|
|
22
31
|
Rake::TestTask.new do |t|
|
23
|
-
|
24
|
-
|
32
|
+
t.warning = true
|
33
|
+
t.verbose = true
|
25
34
|
end
|