win32-file-attributes 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES
CHANGED
@@ -1,2 +1,7 @@
|
|
1
|
+
= 1.0.1 - 8-Apr-2013
|
2
|
+
* Fixed the HANDLE prototypes in the underlying FFI code for 64 bit Ruby.
|
3
|
+
* Fixed the return type for SetFileAttributes, and adjusted the code to match.
|
4
|
+
* Added some tests for constants.
|
5
|
+
|
1
6
|
= 1.0.0 - 26-Nov-2012
|
2
7
|
* Initial release as an independent library.
|
@@ -10,7 +10,7 @@ class File
|
|
10
10
|
extend Windows::File::Functions
|
11
11
|
|
12
12
|
# The version of the win32-file library
|
13
|
-
WIN32_FILE_ATTRIBUTE_VERSION = '1.0.
|
13
|
+
WIN32_FILE_ATTRIBUTE_VERSION = '1.0.1'
|
14
14
|
|
15
15
|
## ABBREVIATED ATTRIBUTE CONSTANTS
|
16
16
|
|
@@ -112,7 +112,7 @@ class File
|
|
112
112
|
|
113
113
|
attributes |= flags
|
114
114
|
|
115
|
-
|
115
|
+
unless SetFileAttributesW(wfile, attributes)
|
116
116
|
raise SystemCallError.new("SetFileAttributes", FFI.errno)
|
117
117
|
end
|
118
118
|
|
@@ -131,7 +131,7 @@ class File
|
|
131
131
|
|
132
132
|
attributes &= ~flags
|
133
133
|
|
134
|
-
|
134
|
+
unless SetFileAttributesW(wfile, attributes)
|
135
135
|
raise SystemCallError.new("SetFileAttributes", FFI.errno)
|
136
136
|
end
|
137
137
|
|
@@ -264,7 +264,7 @@ class File
|
|
264
264
|
attributes &= ~FILE_ATTRIBUTE_ARCHIVE;
|
265
265
|
end
|
266
266
|
|
267
|
-
|
267
|
+
unless SetFileAttributesW(wide_path, attributes)
|
268
268
|
raise SystemCallError.new("SetFileAttributes", FFI.errno)
|
269
269
|
end
|
270
270
|
|
@@ -336,7 +336,7 @@ class File
|
|
336
336
|
attributes &= ~FILE_ATTRIBUTE_HIDDEN;
|
337
337
|
end
|
338
338
|
|
339
|
-
|
339
|
+
unless SetFileAttributesW(wide_path, attributes)
|
340
340
|
raise SystemCallError.new("SetFileAttributes", FFI.errno)
|
341
341
|
end
|
342
342
|
|
@@ -361,7 +361,7 @@ class File
|
|
361
361
|
attributes |= FILE_ATTRIBUTE_NOT_CONTENT_INDEXED;
|
362
362
|
end
|
363
363
|
|
364
|
-
|
364
|
+
unless SetFileAttributesW(wide_path, attributes)
|
365
365
|
raise SystemCallError.new("SetFileAttributes", FFI.errno)
|
366
366
|
end
|
367
367
|
|
@@ -379,7 +379,7 @@ class File
|
|
379
379
|
raise ArgumentError, "only 'true' may be passed as an argument"
|
380
380
|
end
|
381
381
|
|
382
|
-
|
382
|
+
unless SetFileAttributesW(self.path.wincode, FILE_ATTRIBUTE_NORMAL)
|
383
383
|
raise SystemCallError.new("SetFileAttributes", FFI.errno)
|
384
384
|
end
|
385
385
|
|
@@ -408,7 +408,7 @@ class File
|
|
408
408
|
attributes &= ~FILE_ATTRIBUTE_OFFLINE;
|
409
409
|
end
|
410
410
|
|
411
|
-
|
411
|
+
unless SetFileAttributesW(wide_path, attributes)
|
412
412
|
raise SystemCallError.new("SetFileAttributes", FFI.errno)
|
413
413
|
end
|
414
414
|
|
@@ -433,7 +433,7 @@ class File
|
|
433
433
|
attributes &= ~FILE_ATTRIBUTE_READONLY;
|
434
434
|
end
|
435
435
|
|
436
|
-
|
436
|
+
unless SetFileAttributesW(wide_path, attributes)
|
437
437
|
raise SystemCallError.new("SetFileAttributes", FFI.errno)
|
438
438
|
end
|
439
439
|
|
@@ -504,7 +504,7 @@ class File
|
|
504
504
|
attributes &= ~FILE_ATTRIBUTE_SYSTEM;
|
505
505
|
end
|
506
506
|
|
507
|
-
|
507
|
+
unless SetFileAttributesW(wide_path, attributes)
|
508
508
|
raise SystemCallError.new("SetFileAttributes", FFI.errno)
|
509
509
|
end
|
510
510
|
|
@@ -533,7 +533,7 @@ class File
|
|
533
533
|
attributes &= ~FILE_ATTRIBUTE_TEMPORARY;
|
534
534
|
end
|
535
535
|
|
536
|
-
|
536
|
+
unless SetFileAttributesW(wide_path, attributes)
|
537
537
|
raise SystemCallError.new("SetFileAttributes", FFI.errno)
|
538
538
|
end
|
539
539
|
|
@@ -4,13 +4,16 @@ module Windows
|
|
4
4
|
module File
|
5
5
|
module Functions
|
6
6
|
extend FFI::Library
|
7
|
+
typedef :ulong, :dword
|
8
|
+
typedef :uintptr_t, :handle
|
9
|
+
|
7
10
|
ffi_lib :kernel32
|
8
11
|
|
9
|
-
attach_function :CloseHandle, [:
|
10
|
-
attach_function :CreateFileW, [:buffer_in, :
|
11
|
-
attach_function :DeviceIoControl, [:
|
12
|
-
attach_function :GetFileAttributesW, [:buffer_in], :
|
13
|
-
attach_function :SetFileAttributesW, [:buffer_in, :
|
12
|
+
attach_function :CloseHandle, [:handle], :bool
|
13
|
+
attach_function :CreateFileW, [:buffer_in, :dword, :dword, :pointer, :dword, :dword, :handle], :handle
|
14
|
+
attach_function :DeviceIoControl, [:handle, :dword, :pointer, :dword, :pointer, :dword, :pointer, :pointer], :bool
|
15
|
+
attach_function :GetFileAttributesW, [:buffer_in], :dword
|
16
|
+
attach_function :SetFileAttributesW, [:buffer_in, :dword], :bool
|
14
17
|
|
15
18
|
def CTL_CODE(device, function, method, access)
|
16
19
|
((device) << 16) | ((access) << 14) | ((function) << 2) | (method)
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#############################################################################
|
2
|
+
# test_win32_file_attribute_constants.rb
|
3
|
+
#
|
4
|
+
# Test cases for the "shortcut" constants for File attributes.
|
5
|
+
#############################################################################
|
6
|
+
require 'test-unit'
|
7
|
+
require 'win32/file/attributes'
|
8
|
+
|
9
|
+
class TC_Win32_File_Attribute_Constants < Test::Unit::TestCase
|
10
|
+
test "shortcut constants are defined" do
|
11
|
+
assert_not_nil(File::ARCHIVE)
|
12
|
+
assert_not_nil(File::HIDDEN)
|
13
|
+
assert_not_nil(File::NORMAL)
|
14
|
+
assert_not_nil(File::INDEXED)
|
15
|
+
assert_not_nil(File::OFFLINE)
|
16
|
+
assert_not_nil(File::READONLY)
|
17
|
+
assert_not_nil(File::SYSTEM)
|
18
|
+
assert_not_nil(File::TEMPORARY)
|
19
|
+
assert_not_nil(File::CONTENT_INDEXED)
|
20
|
+
end
|
21
|
+
|
22
|
+
test "CONTENT_INDEXED is identical to INDEXED" do
|
23
|
+
assert_equal(File::INDEXED, File::CONTENT_INDEXED)
|
24
|
+
end
|
25
|
+
end
|
@@ -27,7 +27,7 @@ class TC_Win32_File_Attributes < Test::Unit::TestCase
|
|
27
27
|
end
|
28
28
|
|
29
29
|
test "version is set to expected value" do
|
30
|
-
assert_equal('1.0.
|
30
|
+
assert_equal('1.0.1', File::WIN32_FILE_ATTRIBUTE_VERSION)
|
31
31
|
end
|
32
32
|
|
33
33
|
test "temporary? singleton method basic functionality" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: win32-file-attributes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2013-04-08 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: ffi
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- Rakefile
|
64
64
|
- README
|
65
65
|
- test/test_win32_file_attributes.rb
|
66
|
+
- test/test_win32_file_attribute_constants.rb
|
66
67
|
- win32-file-attributes.gemspec
|
67
68
|
homepage: http://github.com/djberg96/win32-file-attributes
|
68
69
|
licenses:
|
@@ -91,3 +92,4 @@ specification_version: 3
|
|
91
92
|
summary: File attribute methods for the File class on MS Windows
|
92
93
|
test_files:
|
93
94
|
- test/test_win32_file_attributes.rb
|
95
|
+
- test/test_win32_file_attribute_constants.rb
|