win32-dir 0.5.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -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" unless defined?(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" unless defined?(Gem)
4
+ gem "ffi"
5
+ end
6
+
7
+ require "ffi" unless defined?(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, %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
+
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, %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
+ attach_pfunc :GetFileAttributesW, [:buffer_in], :dword
46
+ attach_pfunc :GetLastError, [], :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
+ 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
+ (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
+ 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" unless defined?(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
@@ -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,37 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: win32-dir
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
8
8
  - Park Heesob
9
9
  autorequire:
10
10
  bindir: bin
11
- cert_chain:
12
- - |
13
- -----BEGIN CERTIFICATE-----
14
- MIIDcDCCAligAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MREwDwYDVQQDDAhkam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P+g05p8bRNKjZSA2iImM/GyYZ
31
- EJYzxdPOrx2n6NYR3Hk+vHP0U7UBSveI6+qx+ndQYaeyCn+GRX2PKS9h66YF/Q1V
32
- tGSHgAmcLlkdGgan182qsE/4kKM=
33
- -----END CERTIFICATE-----
34
- date: 2015-10-20 00:00:00.000000000 Z
11
+ cert_chain: []
12
+ date: 2020-11-30 00:00:00.000000000 Z
35
13
  dependencies:
36
14
  - !ruby/object:Gem::Dependency
37
15
  name: ffi
@@ -47,34 +25,6 @@ dependencies:
47
25
  - - ">="
48
26
  - !ruby/object:Gem::Version
49
27
  version: 1.0.0
50
- - !ruby/object:Gem::Dependency
51
- name: rake
52
- requirement: !ruby/object:Gem::Requirement
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: '0'
57
- type: :development
58
- prerelease: false
59
- version_requirements: !ruby/object:Gem::Requirement
60
- requirements:
61
- - - ">="
62
- - !ruby/object:Gem::Version
63
- version: '0'
64
- - !ruby/object:Gem::Dependency
65
- name: test-unit
66
- requirement: !ruby/object:Gem::Requirement
67
- requirements:
68
- - - ">="
69
- - !ruby/object:Gem::Version
70
- version: 2.4.0
71
- type: :development
72
- prerelease: false
73
- version_requirements: !ruby/object:Gem::Requirement
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- version: 2.4.0
78
28
  description: |2
79
29
  The win32-dir library provides extra methods and constants for the
80
30
  builtin Dir class. The constants provide a convenient way to identify
@@ -84,25 +34,15 @@ description: |2
84
34
  email: djberg96@gmail.com
85
35
  executables: []
86
36
  extensions: []
87
- extra_rdoc_files:
88
- - README
89
- - CHANGES
90
- - MANIFEST
37
+ extra_rdoc_files: []
91
38
  files:
92
- - CHANGES
93
- - MANIFEST
94
- - README
95
- - Rakefile
96
- - certs/djberg96_pub.pem
97
- - examples/dir_example.rb
98
39
  - lib/win32-dir.rb
99
40
  - lib/win32/dir.rb
100
41
  - lib/win32/dir/constants.rb
101
42
  - lib/win32/dir/functions.rb
102
43
  - lib/win32/dir/structs.rb
103
- - test/test_win32_dir.rb
104
- - win32-dir.gemspec
105
- homepage: http://github.com/djberg96/win32-dir
44
+ - lib/win32/dir/version.rb
45
+ homepage: https://github.com/chef/win32-dir
106
46
  licenses:
107
47
  - Artistic 2.0
108
48
  metadata: {}
@@ -114,17 +54,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
114
54
  requirements:
115
55
  - - ">="
116
56
  - !ruby/object:Gem::Version
117
- version: 1.9.2
57
+ version: '2.4'
118
58
  required_rubygems_version: !ruby/object:Gem::Requirement
119
59
  requirements:
120
60
  - - ">="
121
61
  - !ruby/object:Gem::Version
122
62
  version: '0'
123
63
  requirements: []
124
- rubyforge_project:
125
- rubygems_version: 2.4.8
64
+ rubygems_version: 3.0.3
126
65
  signing_key:
127
66
  specification_version: 4
128
67
  summary: Extra constants and methods for the Dir class on Windows.
129
- test_files:
130
- - test/test_win32_dir.rb
68
+ test_files: []
Binary file
data.tar.gz.sig DELETED
Binary file
data/CHANGES DELETED
@@ -1,121 +0,0 @@
1
- == 0.5.1 - 20-Oct-2015
2
- * The gem is now signed.
3
- * The Rakefile gem tasks now assume Rubygems 2.x.
4
- * Added a win32-dir.rb file for convenience.
5
-
6
- == 0.5.0 - 15-Oct-2014
7
- * Fixed an encoding error in an error message in the Dir.read_junction method.
8
- Thanks go to topac for the spot and patch.
9
- * Replaced File.exists? with File.exist? in the test suite to avoid warnings
10
- in Ruby 2.1 and later.
11
- * Do not let the version number fool you, this is not a major release. I
12
- simply ran out of version numbers.
13
-
14
- == 0.4.9 - 2-Jul-2014
15
- * Fixed the INVALID_FILE_ATTRIBUTES constant. It's only a 32-bit value.
16
- Thanks go to Ethan Brown for the patch.
17
- * Use relative_require instead of manually doing things.
18
- * Removed rubyforge_project from gemspec.
19
- * Added a string_check to the Dir.junction? method.
20
-
21
- == 0.4.8 - 27-Apr-2014
22
- * More closely mimic Ruby's stringiness checks for overrided methods.
23
-
24
- == 0.4.7 - 26-Apr-2014
25
- * All arguments to methods are now interpolated so that they'll use whatever
26
- to_str implemenation the argument provides instead of assuming String
27
- arguments. This change was made because it turns out that at least some
28
- of the overridden methods in MRI accept Pathname objects. Thanks go to
29
- Josh Cooper/Puppet Labs for the spot.
30
- * Refactored the Dir.getwd method to use bonafide FFI buffers instead of
31
- naked Ruby char buffers.
32
- * Internally various functions now fail in the event that the resulting
33
- paths would exceed their buffers.
34
-
35
- == 0.4.6 - 21-Oct-2013
36
- * Fixed the INVALID_HANDLE_VALUE and INVALID_FILE_ATTRIBUTES constants for
37
- 64-bit versions of Ruby.
38
- * Added Rake as a development dependency.
39
-
40
- == 0.4.5 - 23-Sep-2013
41
- * Yet another encoding fix, this time one that affected JRuby.
42
- * Fixed the Dir[] and Dir.glob methods so they match the spec. Thanks go
43
- to Chris Westbrook for the spot.
44
-
45
- == 0.4.4 - 22-Sep-2013
46
- * Yet another encoding fix. Thanks go to Rob Reynolds for the patch.
47
-
48
- == 0.4.3 - 24-Jul-2013
49
- * Changed the Dir.read_junction and CSIDL constant strings so that they
50
- use the default external encoding instead of UTF-16LE. This means that
51
- they will now work with methods like File.join. Thanks go to Josh Cooper
52
- for the patches.
53
- * Some changes for internal handling of making FFI functions private.
54
- * Updated gem:create task for rubygems 2.
55
-
56
- == 0.4.2 - 8-Apr-2013
57
- * Fixed the HANDLE function prototypes in the underlying FFI code and added
58
- some custom typedefs for convenience. This affects 64 bit Ruby code.
59
-
60
- == 0.4.1 - 2-Oct-2012
61
- * Added the Dir.read_junction method. Thanks go to Gabriel Wilkins for the patch.
62
-
63
- == 0.4.0 - 29-Jun-2012
64
- * Conversion to FFI. Should work with JRuby now.
65
- * If current versions of Dir::XXX constant values cannot be found
66
- then default values are tried.
67
- * Now requires Ruby 1.9 or later.
68
-
69
- == 0.3.7 - 18-Jul-2010
70
- * Modified Dir.glob and Dir[] to handle backslashes in path names.
71
- * Added tests for the modified Dir.glob and Dir[] behavior.
72
- * Removed the old non-gem install Rake task.
73
-
74
- == 0.3.6 - 6-Feb-2010
75
- * Bug fixes for Ruby 1.9.x. Thanks go to Kendall Gifford for the spot and
76
- the patch.
77
- * Minor refactoring of the Dir.create_junction method. This fixed a bug for
78
- Ruby 1.9.x, but was also a little cleaner in general.
79
- * Some Rakefile task and gemspec updates.
80
-
81
- == 0.3.5 - 6-Aug-2009
82
- * Changed the license to Artistic 2.0.
83
- * Updated the gemspec, including the addition of a license attribute and
84
- test-unit as a development dependency.
85
-
86
- == 0.3.4 - 5-May-2009
87
- * Redefined the Dir.getwd (and the Dir.pwd alias) to always return a
88
- normalized path.
89
- * Some gemspec updates.
90
-
91
- == 0.3.3 - 30-Mar-2009
92
- * Virtual folders like Dir::CONTROL, which were previously almost always nil,
93
- are now set to their display name.
94
- * Fixed a bug in the create_junction method.
95
- * Added an 'example' rake task to run the example code.
96
- * Renamed the example program from dir_test.rb to dir_example.rb to prevent
97
- any potential confusion that it's a genuine test file.
98
-
99
- == 0.3.2 - 25-Jul-2007
100
- * Added a Rakefile with tasks for testing and installation.
101
- * Removed the install.rb file (the Rakefile handles installation).
102
- * Minor updates the README, MANIFEST, and test file.
103
-
104
- == 0.3.1 - 16-Oct-2006
105
- * Added the Dir.empty? method.
106
- * Changed the Dir.reparse_dir? method to Dir.junction? (but kept an alias
107
- for backwards compatibility).
108
- * Added rdoc for Dir.junction? (oops).
109
- * Some test tweaks and additions.
110
-
111
- == 0.3.0 - 28-May-2006
112
- * Now pure Ruby.
113
- * Now has a gem.
114
- * Added a VERSION constant.
115
-
116
- == 0.2.0 - 27-Jun-2005
117
- * Added the Dir.create_junction and Dir.reparse_dir? methods.
118
- * Added corresponding tests and documentation.
119
-
120
- == 0.1.0 - 25-Feb-2005
121
- * Initial release