win32-dir 0.4.7 → 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.
@@ -1,4 +1,4 @@
1
- require 'ffi'
1
+ require "ffi" unless defined?(FFI)
2
2
 
3
3
  module Dir::Constants
4
4
  include FFI::Library
@@ -18,6 +18,9 @@ module Dir::Constants
18
18
  SHGFI_DISPLAYNAME = 0x000000200
19
19
  SHGFI_PIDL = 0x000000008
20
20
 
21
- INVALID_HANDLE_VALUE = FFI::Pointer.new(-1).address
22
- INVALID_FILE_ATTRIBUTES = FFI::Pointer.new(-1).address
21
+ # ((DWORD)-1)
22
+ INVALID_FILE_ATTRIBUTES = 0xFFFFFFFF
23
+
24
+ # ((HANDLE)-1)
25
+ INVALID_HANDLE_VALUE = FFI::Pointer.new(-1).address
23
26
  end
@@ -1,10 +1,10 @@
1
1
  # Necessary to force JRuby to use the gem, not its builtin version
2
- if RUBY_PLATFORM == 'java'
3
- require 'rubygems'
4
- gem 'ffi'
2
+ if RUBY_PLATFORM == "java"
3
+ require "rubygems" unless defined?(Gem)
4
+ gem "ffi"
5
5
  end
6
6
 
7
- require 'ffi'
7
+ require "ffi" unless defined?(FFI)
8
8
 
9
9
  module Dir::Functions
10
10
  module FFI::Library
@@ -25,9 +25,9 @@ module Dir::Functions
25
25
  ffi_lib :shell32
26
26
  ffi_convention :stdcall
27
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
28
+ attach_pfunc :SHGetFolderPathW, %i{hwnd int handle dword buffer_out}, :dword
29
+ attach_pfunc :SHGetFolderLocation, %i{hwnd int handle dword ptr}, :dword
30
+ attach_pfunc :SHGetFileInfo, %i{uint64 dword ptr uint uint}, :dword
31
31
 
32
32
  ffi_lib :shlwapi
33
33
  ffi_convention :stdcall
@@ -38,15 +38,15 @@ module Dir::Functions
38
38
  ffi_convention :stdcall
39
39
 
40
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
41
+ attach_pfunc :CreateDirectoryW, %i{buffer_in ptr}, :bool
42
+ attach_pfunc :CreateFileW, %i{buffer_in dword dword ptr dword dword handle}, :handle
43
+ attach_pfunc :DeviceIoControl, %i{handle dword ptr dword ptr dword ptr ptr}, :bool
44
+ attach_pfunc :GetCurrentDirectoryW, %i{dword buffer_out}, :dword
45
45
  attach_pfunc :GetFileAttributesW, [:buffer_in], :dword
46
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
47
+ attach_pfunc :GetShortPathNameW, %i{buffer_in buffer_out dword}, :dword
48
+ attach_pfunc :GetLongPathNameW, %i{buffer_in buffer_out dword}, :dword
49
+ attach_pfunc :GetFullPathNameW, %i{buffer_in dword buffer_out ptr}, :dword
50
50
  attach_pfunc :RemoveDirectoryW, [:buffer_in], :bool
51
51
  end
52
52
 
@@ -54,13 +54,13 @@ class String
54
54
  # Convenience method for converting strings to UTF-16LE for wide character
55
55
  # functions that require it.
56
56
  def wincode
57
- (self.tr(File::SEPARATOR, File::ALT_SEPARATOR) + 0.chr).encode('UTF-16LE')
57
+ (tr(File::SEPARATOR, File::ALT_SEPARATOR) + 0.chr).encode("UTF-16LE")
58
58
  end
59
59
 
60
60
  # Read a wide character string up until the first double null, and delete
61
61
  # any remaining null characters.
62
62
  def wstrip
63
- self.force_encoding('UTF-16LE').encode('UTF-8',:invalid=>:replace,:undef=>:replace).
64
- split("\x00")[0].encode(Encoding.default_external)
63
+ force_encoding("UTF-16LE").encode("UTF-8", invalid: :replace, undef: :replace)
64
+ .split("\x00")[0].encode(Encoding.default_external)
65
65
  end
66
66
  end
@@ -1,4 +1,4 @@
1
- require 'ffi'
1
+ require "ffi" unless defined?(FFI)
2
2
 
3
3
  module Dir::Structs
4
4
  extend FFI::Library
@@ -0,0 +1,6 @@
1
+ module Win32
2
+ class Dir
3
+ # The version of the win32-taskscheduler library
4
+ VERSION = "0.7.2".freeze
5
+ end
6
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: win32-dir
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.7
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -9,50 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-26 00:00:00.000000000 Z
12
+ date: 2020-11-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - '>='
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: 1.0.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - '>='
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: 1.0.0
28
- - !ruby/object:Gem::Dependency
29
- name: rake
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - '>='
33
- - !ruby/object:Gem::Version
34
- version: '0'
35
- type: :development
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - '>='
40
- - !ruby/object:Gem::Version
41
- version: '0'
42
- - !ruby/object:Gem::Dependency
43
- name: test-unit
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - '>='
47
- - !ruby/object:Gem::Version
48
- version: 2.4.0
49
- type: :development
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - '>='
54
- - !ruby/object:Gem::Version
55
- version: 2.4.0
56
28
  description: |2
57
29
  The win32-dir library provides extra methods and constants for the
58
30
  builtin Dir class. The constants provide a convenient way to identify
@@ -62,23 +34,15 @@ description: |2
62
34
  email: djberg96@gmail.com
63
35
  executables: []
64
36
  extensions: []
65
- extra_rdoc_files:
66
- - README
67
- - CHANGES
68
- - MANIFEST
37
+ extra_rdoc_files: []
69
38
  files:
70
- - CHANGES
71
- - MANIFEST
72
- - README
73
- - Rakefile
74
- - examples/dir_example.rb
39
+ - lib/win32-dir.rb
75
40
  - lib/win32/dir.rb
76
41
  - lib/win32/dir/constants.rb
77
42
  - lib/win32/dir/functions.rb
78
43
  - lib/win32/dir/structs.rb
79
- - test/test_win32_dir.rb
80
- - win32-dir.gemspec
81
- homepage: http://github.com/djberg96/win32-dir
44
+ - lib/win32/dir/version.rb
45
+ homepage: https://github.com/chef/win32-dir
82
46
  licenses:
83
47
  - Artistic 2.0
84
48
  metadata: {}
@@ -88,19 +52,17 @@ require_paths:
88
52
  - lib
89
53
  required_ruby_version: !ruby/object:Gem::Requirement
90
54
  requirements:
91
- - - '>='
55
+ - - ">="
92
56
  - !ruby/object:Gem::Version
93
- version: 1.9.2
57
+ version: '2.4'
94
58
  required_rubygems_version: !ruby/object:Gem::Requirement
95
59
  requirements:
96
- - - '>='
60
+ - - ">="
97
61
  - !ruby/object:Gem::Version
98
62
  version: '0'
99
63
  requirements: []
100
- rubyforge_project: win32utils
101
- rubygems_version: 2.2.2
64
+ rubygems_version: 3.0.3
102
65
  signing_key:
103
66
  specification_version: 4
104
67
  summary: Extra constants and methods for the Dir class on Windows.
105
- test_files:
106
- - test/test_win32_dir.rb
68
+ test_files: []
data/CHANGES DELETED
@@ -1,98 +0,0 @@
1
- == 0.4.7 - 26-Apr-2014
2
- * All arguments to methods are now interpolated so that they'll use whatever
3
- to_str implemenation the argument provides instead of assuming String
4
- arguments. This change was made because it turns out that at least some
5
- of the overridden methods in MRI accept Pathname objects. Thanks go to
6
- Josh Cooper/Puppet Labs for the spot.
7
- * Refactored the Dir.getwd method to use bonafide FFI buffers instead of
8
- naked Ruby char buffers.
9
- * Internally various functions now fail in the event that the resulting
10
- paths would exceed their buffers.
11
-
12
- == 0.4.6 - 21-Oct-2013
13
- * Fixed the INVALID_HANDLE_VALUE and INVALID_FILE_ATTRIBUTES constants for
14
- 64-bit versions of Ruby.
15
- * Added Rake as a development dependency.
16
-
17
- == 0.4.5 - 23-Sep-2013
18
- * Yet another encoding fix, this time one that affected JRuby.
19
- * Fixed the Dir[] and Dir.glob methods so they match the spec. Thanks go
20
- to Chris Westbrook for the spot.
21
-
22
- == 0.4.4 - 22-Sep-2013
23
- * Yet another encoding fix. Thanks go to Rob Reynolds for the patch.
24
-
25
- == 0.4.3 - 24-Jul-2013
26
- * Changed the Dir.read_junction and CSIDL constant strings so that they
27
- use the default external encoding instead of UTF-16LE. This means that
28
- they will now work with methods like File.join. Thanks go to Josh Cooper
29
- for the patches.
30
- * Some changes for internal handling of making FFI functions private.
31
- * Updated gem:create task for rubygems 2.
32
-
33
- == 0.4.2 - 8-Apr-2013
34
- * Fixed the HANDLE function prototypes in the underlying FFI code and added
35
- some custom typedefs for convenience. This affects 64 bit Ruby code.
36
-
37
- == 0.4.1 - 2-Oct-2012
38
- * Added the Dir.read_junction method. Thanks go to Gabriel Wilkins for the patch.
39
-
40
- == 0.4.0 - 29-Jun-2012
41
- * Conversion to FFI. Should work with JRuby now.
42
- * If current versions of Dir::XXX constant values cannot be found
43
- then default values are tried.
44
- * Now requires Ruby 1.9 or later.
45
-
46
- == 0.3.7 - 18-Jul-2010
47
- * Modified Dir.glob and Dir[] to handle backslashes in path names.
48
- * Added tests for the modified Dir.glob and Dir[] behavior.
49
- * Removed the old non-gem install Rake task.
50
-
51
- == 0.3.6 - 6-Feb-2010
52
- * Bug fixes for Ruby 1.9.x. Thanks go to Kendall Gifford for the spot and
53
- the patch.
54
- * Minor refactoring of the Dir.create_junction method. This fixed a bug for
55
- Ruby 1.9.x, but was also a little cleaner in general.
56
- * Some Rakefile task and gemspec updates.
57
-
58
- == 0.3.5 - 6-Aug-2009
59
- * Changed the license to Artistic 2.0.
60
- * Updated the gemspec, including the addition of a license attribute and
61
- test-unit as a development dependency.
62
-
63
- == 0.3.4 - 5-May-2009
64
- * Redefined the Dir.getwd (and the Dir.pwd alias) to always return a
65
- normalized path.
66
- * Some gemspec updates.
67
-
68
- == 0.3.3 - 30-Mar-2009
69
- * Virtual folders like Dir::CONTROL, which were previously almost always nil,
70
- are now set to their display name.
71
- * Fixed a bug in the create_junction method.
72
- * Added an 'example' rake task to run the example code.
73
- * Renamed the example program from dir_test.rb to dir_example.rb to prevent
74
- any potential confusion that it's a genuine test file.
75
-
76
- == 0.3.2 - 25-Jul-2007
77
- * Added a Rakefile with tasks for testing and installation.
78
- * Removed the install.rb file (the Rakefile handles installation).
79
- * Minor updates the README, MANIFEST, and test file.
80
-
81
- == 0.3.1 - 16-Oct-2006
82
- * Added the Dir.empty? method.
83
- * Changed the Dir.reparse_dir? method to Dir.junction? (but kept an alias
84
- for backwards compatibility).
85
- * Added rdoc for Dir.junction? (oops).
86
- * Some test tweaks and additions.
87
-
88
- == 0.3.0 - 28-May-2006
89
- * Now pure Ruby.
90
- * Now has a gem.
91
- * Added a VERSION constant.
92
-
93
- == 0.2.0 - 27-Jun-2005
94
- * Added the Dir.create_junction and Dir.reparse_dir? methods.
95
- * Added corresponding tests and documentation.
96
-
97
- == 0.1.0 - 25-Feb-2005
98
- * Initial release
data/MANIFEST DELETED
@@ -1,8 +0,0 @@
1
- * README
2
- * MANIFEST
3
- * CHANGES
4
- * Rakefile
5
- * win32-dir.gemspec
6
- * examples/dir_example.rb
7
- * lib/win32/dir.rb
8
- * test/test_win32_dir.rb
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-2014 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