win32-file 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +8 -1
- data/README +19 -26
- data/lib/win32/file.rb +70 -33
- data/test/test_win32_file_attributes.rb +2 -2
- data/test/test_win32_file_encryption.rb +1 -1
- data/test/test_win32_file_path.rb +1 -1
- data/test/test_win32_file_security.rb +1 -1
- data/test/test_win32_file_stat.rb +1 -1
- data/win32-file.gemspec +30 -24
- metadata +18 -17
data/CHANGES
CHANGED
@@ -1,6 +1,13 @@
|
|
1
|
+
== 0.6.2 - 21-Aug-2009
|
2
|
+
* Changed the license to Artistic 2.0.
|
3
|
+
* Several gemspec updates, including the license and description.
|
4
|
+
* Refactored the File.attributes method so that it isn't making a bunch
|
5
|
+
of calls to File::Stat.
|
6
|
+
* Some documentation updates.
|
7
|
+
|
1
8
|
== 0.6.1 - 9-Feb-2009
|
2
9
|
* Fixed a bug in the custom File.directory? method with regards to
|
3
|
-
non-existent directories.
|
10
|
+
non-existent directories. Thanks go to Montgomery Kosma for the spot.
|
4
11
|
|
5
12
|
== 0.6.0 - 14-Nov-2008
|
6
13
|
* Converted methods to use wide character handling.
|
data/README
CHANGED
@@ -1,16 +1,18 @@
|
|
1
|
-
|
1
|
+
== Description
|
2
2
|
Extra or redefined methods for the File class on MS Windows.
|
3
3
|
|
4
|
-
|
4
|
+
== Prerequisites
|
5
5
|
* Ruby 1.8.0 or later
|
6
6
|
* windows-pr 0.3.0 or later
|
7
7
|
* win32-file-stat 1.2.0 or later
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
== Installation
|
10
|
+
=== Gem installation
|
11
|
+
gem install win32-file
|
12
|
+
=== Local installation
|
13
|
+
rake install
|
12
14
|
|
13
|
-
|
15
|
+
== Synopsis
|
14
16
|
require 'win32/file'
|
15
17
|
|
16
18
|
p File.hidden?(somefile)
|
@@ -20,7 +22,7 @@ Extra or redefined methods for the File class on MS Windows.
|
|
20
22
|
fh.hidden = true
|
21
23
|
}
|
22
24
|
|
23
|
-
|
25
|
+
== Class methods added - see documentation for details
|
24
26
|
* File.attributes
|
25
27
|
* File.archive?
|
26
28
|
* File.compressed?
|
@@ -44,7 +46,7 @@ Extra or redefined methods for the File class on MS Windows.
|
|
44
46
|
* File.system?
|
45
47
|
* File.temporary?
|
46
48
|
|
47
|
-
|
49
|
+
== Instance methods added - see documentation for details
|
48
50
|
* File#archive=
|
49
51
|
* File#compressed=
|
50
52
|
* File#hidden=
|
@@ -56,7 +58,7 @@ Extra or redefined methods for the File class on MS Windows.
|
|
56
58
|
* File#system=
|
57
59
|
* File#temporary=
|
58
60
|
|
59
|
-
|
61
|
+
== Class methods redefined and the reason for redefining them
|
60
62
|
* File.basename # UNC path issues
|
61
63
|
* File.blksize # Wasn't implemented
|
62
64
|
* File.blockdev? # Wasn't implemented
|
@@ -65,30 +67,21 @@ Extra or redefined methods for the File class on MS Windows.
|
|
65
67
|
* File.size # 2GB limitation
|
66
68
|
* File.split # UNC path issues
|
67
69
|
|
68
|
-
|
69
|
-
For all the unit tests to pass, the 'sometestfile.txt' file must have the
|
70
|
-
'archive' and 'readonly' attributes set. Although I have them set on the
|
71
|
-
file when I create the zip archive, it seems that file attributes aren't
|
72
|
-
guaranteed to survive the process.
|
73
|
-
|
74
|
-
So, please change the file attributes manually if needed before running the
|
75
|
-
test suite. You can do this by right-clicking on the file in Explorer and
|
76
|
-
selecting 'properties'. The readonly attribute check-box is at the bottom
|
77
|
-
left corner. To get to the archive attribute click on the 'Advanced' tab.
|
78
|
-
You should see a checkbox at the top.
|
79
|
-
|
80
|
-
= Known issues or bugs
|
70
|
+
== Known issues or bugs
|
81
71
|
None that I'm aware of. Please report any bugs you find on the project page
|
82
72
|
at http://www.rubyforge.org/projects/win32utils.
|
83
73
|
|
84
|
-
|
85
|
-
|
74
|
+
== License
|
75
|
+
Artistic 2.0
|
76
|
+
|
77
|
+
== Copyright
|
78
|
+
(C) 2003-2009, Daniel J. Berger, All Rights Reserved
|
86
79
|
|
87
|
-
|
80
|
+
== Warranty
|
88
81
|
This package is provided "as is" and without any express or
|
89
82
|
implied warranties, including, without limitation, the implied
|
90
83
|
warranties of merchantability and fitness for a particular purpose.
|
91
84
|
|
92
|
-
|
85
|
+
== Authors
|
93
86
|
* Daniel J. Berger
|
94
87
|
* Park Heesob
|
data/lib/win32/file.rb
CHANGED
@@ -19,31 +19,63 @@ class File
|
|
19
19
|
extend Windows::Handle
|
20
20
|
|
21
21
|
# The version of the win32-file library
|
22
|
-
WIN32_FILE_VERSION = '0.6.
|
22
|
+
WIN32_FILE_VERSION = '0.6.2'
|
23
23
|
|
24
24
|
# Abbreviated attribute constants for convenience
|
25
25
|
|
26
|
-
|
26
|
+
# The file or directory is an archive. Typically used to mark files for
|
27
|
+
# backup or removal.
|
28
|
+
ARCHIVE = FILE_ATTRIBUTE_ARCHIVE
|
29
|
+
|
30
|
+
# The file or directory is encrypted. For a file, this means that all
|
31
|
+
# data in the file is encrypted. For a directory, this means that
|
32
|
+
# encryption is # the default for newly created files and subdirectories.
|
27
33
|
COMPRESSED = FILE_ATTRIBUTE_COMPRESSED
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
|
35
|
+
# The file is hidden. Not included in an ordinary directory listing.
|
36
|
+
HIDDEN = FILE_ATTRIBUTE_HIDDEN
|
37
|
+
|
38
|
+
# A file that does not have any other attributes set.
|
39
|
+
NORMAL = FILE_ATTRIBUTE_NORMAL
|
40
|
+
|
41
|
+
# The data of a file is not immediately available. This attribute indicates
|
42
|
+
# that file data is physically moved to offline storage.
|
43
|
+
OFFLINE = FILE_ATTRIBUTE_OFFLINE
|
44
|
+
|
45
|
+
# The file is read only. Apps can read it, but not write to it or delete it.
|
46
|
+
READONLY = FILE_ATTRIBUTE_READONLY
|
47
|
+
|
48
|
+
# The file is part of or used exclusively by an operating system.
|
49
|
+
SYSTEM = FILE_ATTRIBUTE_SYSTEM
|
50
|
+
|
51
|
+
# The file is being used for temporary storage.
|
52
|
+
TEMPORARY = FILE_ATTRIBUTE_TEMPORARY
|
53
|
+
|
54
|
+
# The file or directory is to be indexed by the content indexing service.
|
55
|
+
# Note that we have inverted the traditional definition.
|
56
|
+
INDEXED = 0x0002000
|
57
|
+
|
58
|
+
# Synonym for File::INDEXED.
|
59
|
+
CONTENT_INDEXED = INDEXED
|
36
60
|
|
37
61
|
# Custom Security rights
|
38
62
|
|
63
|
+
# Full security rights - read, write, append, execute, and delete.
|
39
64
|
FULL = STANDARD_RIGHTS_ALL | FILE_READ_DATA | FILE_WRITE_DATA |
|
40
65
|
FILE_APPEND_DATA | FILE_READ_EA | FILE_WRITE_EA | FILE_EXECUTE |
|
41
66
|
FILE_DELETE_CHILD | FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES
|
42
67
|
|
68
|
+
# Generic write, generic read, execute and delete privileges
|
43
69
|
CHANGE = FILE_GENERIC_WRITE | FILE_GENERIC_READ | FILE_EXECUTE | DELETE
|
44
|
-
|
45
|
-
|
46
|
-
|
70
|
+
|
71
|
+
# Read and execute privileges
|
72
|
+
READ = FILE_GENERIC_READ | FILE_EXECUTE
|
73
|
+
|
74
|
+
# Add privileges
|
75
|
+
ADD = 0x001201bf
|
76
|
+
|
77
|
+
# :stopdoc:
|
78
|
+
|
47
79
|
SECURITY_RIGHTS = {
|
48
80
|
'FULL' => FULL,
|
49
81
|
'DELETE' => DELETE,
|
@@ -52,9 +84,14 @@ class File
|
|
52
84
|
'ADD' => ADD
|
53
85
|
}
|
54
86
|
|
87
|
+
# :startdoc:
|
88
|
+
|
55
89
|
### Class Methods
|
56
90
|
|
57
91
|
class << self
|
92
|
+
|
93
|
+
# :stopdoc:
|
94
|
+
|
58
95
|
# Strictly for making this code -w clean. They are removed later.
|
59
96
|
alias basename_orig basename
|
60
97
|
alias blockdev_orig blockdev?
|
@@ -69,11 +106,13 @@ class File
|
|
69
106
|
alias symlink_orig symlink
|
70
107
|
alias symlink_orig? symlink?
|
71
108
|
|
109
|
+
# :startdoc:
|
110
|
+
|
72
111
|
## Security
|
73
112
|
|
74
113
|
# Sets the file permissions for the given file name. The 'permissions'
|
75
114
|
# argument is a hash with an account name as the key, and the various
|
76
|
-
# permission constants as possible values.
|
115
|
+
# permission constants as possible values. The possible constant values
|
77
116
|
# are:
|
78
117
|
#
|
79
118
|
# * FILE_READ_DATA
|
@@ -370,8 +409,6 @@ class File
|
|
370
409
|
# Requires exclusive access to the file being encrypted, and will fail if
|
371
410
|
# another process is using the file. If the file is compressed,
|
372
411
|
# EncryptFile will decompress the file before encrypting it.
|
373
|
-
#
|
374
|
-
# Windows 2000 or later only.
|
375
412
|
#
|
376
413
|
def encrypt(file)
|
377
414
|
unless EncryptFileW(multi_to_wide(file))
|
@@ -796,27 +833,27 @@ class File
|
|
796
833
|
# temporary
|
797
834
|
#
|
798
835
|
def self.attributes(file)
|
799
|
-
|
800
|
-
attributes = GetFileAttributesW(file)
|
801
|
-
arr = []
|
836
|
+
attributes = GetFileAttributesW(multi_to_wide(file))
|
802
837
|
|
803
838
|
if attributes == INVALID_FILE_ATTRIBUTES
|
804
839
|
raise ArgumentError, get_last_error
|
805
840
|
end
|
806
|
-
|
807
|
-
arr
|
808
|
-
|
809
|
-
arr
|
810
|
-
arr
|
811
|
-
arr
|
812
|
-
arr
|
813
|
-
arr
|
814
|
-
arr
|
815
|
-
arr
|
816
|
-
arr
|
817
|
-
arr
|
818
|
-
arr
|
819
|
-
arr
|
841
|
+
|
842
|
+
arr = []
|
843
|
+
|
844
|
+
arr << 'archive' if attributes & FILE_ATTRIBUTE_ARCHIVE > 0
|
845
|
+
arr << 'compressed' if attributes & FILE_ATTRIBUTE_COMPRESSED > 0
|
846
|
+
arr << 'directory' if attributes & FILE_ATTRIBUTE_DIRECTORY > 0
|
847
|
+
arr << 'encrypted' if attributes & FILE_ATTRIBUTE_ENCRYPTED > 0
|
848
|
+
arr << 'hidden' if attributes & FILE_ATTRIBUTE_HIDDEN > 0
|
849
|
+
arr << 'indexed' if attributes & FILE_ATTRIBUTE_NOT_CONTENT_INDEXED == 0
|
850
|
+
arr << 'normal' if attributes & FILE_ATTRIBUTE_NORMAL > 0
|
851
|
+
arr << 'offline' if attributes & FILE_ATTRIBUTE_OFFLINE > 0
|
852
|
+
arr << 'readonly' if attributes & FILE_ATTRIBUTE_READONLY > 0
|
853
|
+
arr << 'reparse_point' if attributes & FILE_ATTRIBUTE_REPARSE_POINT > 0
|
854
|
+
arr << 'sparse' if attributes & FILE_ATTRIBUTE_SPARSE_FILE > 0
|
855
|
+
arr << 'system' if attributes & FILE_ATTRIBUTE_SYSTEM > 0
|
856
|
+
arr << 'temporary' if attributes & FILE_ATTRIBUTE_TEMPORARY > 0
|
820
857
|
|
821
858
|
arr
|
822
859
|
end
|
@@ -15,7 +15,7 @@ class TC_Win32_File_Attributes < Test::Unit::TestCase
|
|
15
15
|
extend Windows::File
|
16
16
|
|
17
17
|
def self.startup
|
18
|
-
Dir.chdir(
|
18
|
+
Dir.chdir(File.dirname(File.expand_path(File.basename(__FILE__))))
|
19
19
|
@@file = File.join(Dir.pwd, 'test_file.txt')
|
20
20
|
File.open(@@file, 'w'){ |fh| fh.puts "This is a test." }
|
21
21
|
end
|
@@ -26,7 +26,7 @@ class TC_Win32_File_Attributes < Test::Unit::TestCase
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_version
|
29
|
-
assert_equal('0.6.
|
29
|
+
assert_equal('0.6.2', File::WIN32_FILE_VERSION)
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_is_directory
|
@@ -14,7 +14,7 @@ require 'win32/file'
|
|
14
14
|
|
15
15
|
class TC_Win32_File_Encryption < Test::Unit::TestCase
|
16
16
|
def self.startup
|
17
|
-
Dir.chdir(
|
17
|
+
Dir.chdir(File.dirname(File.expand_path(File.basename(__FILE__))))
|
18
18
|
@@file = File.join(Dir.pwd, 'encryption_test.txt')
|
19
19
|
File.open(@@file, 'w'){ |fh| fh.puts "This is an encryption test." }
|
20
20
|
end
|
@@ -12,7 +12,7 @@ require 'win32/file'
|
|
12
12
|
|
13
13
|
class TC_Win32_File_Path < Test::Unit::TestCase
|
14
14
|
def self.startup
|
15
|
-
Dir.chdir(
|
15
|
+
Dir.chdir(File.dirname(File.expand_path(File.basename(__FILE__))))
|
16
16
|
@@file = File.join(Dir.pwd, 'path_test.txt')
|
17
17
|
File.open(@@file, 'w'){ |fh| fh.puts "This is a path test." }
|
18
18
|
end
|
@@ -16,7 +16,7 @@ require 'socket'
|
|
16
16
|
|
17
17
|
class TC_Win32_File_Security < Test::Unit::TestCase
|
18
18
|
def self.startup
|
19
|
-
Dir.chdir(
|
19
|
+
Dir.chdir(File.dirname(File.expand_path(File.basename(__FILE__))))
|
20
20
|
@@host = Socket.gethostname
|
21
21
|
@@file = File.join(Dir.pwd, 'security_test.txt')
|
22
22
|
File.open(@@file, 'w'){ |fh| fh.puts "This is a security test." }
|
@@ -15,7 +15,7 @@ class TC_Win32_File_Stat < Test::Unit::TestCase
|
|
15
15
|
extend Windows::Volume
|
16
16
|
|
17
17
|
def self.startup
|
18
|
-
Dir.chdir(
|
18
|
+
Dir.chdir(File.dirname(File.expand_path(File.basename(__FILE__))))
|
19
19
|
@@file = File.join(Dir.pwd, 'stat_test.txt')
|
20
20
|
File.open(@@file, 'w'){ |fh| fh.puts "This is a test." }
|
21
21
|
|
data/win32-file.gemspec
CHANGED
@@ -1,28 +1,34 @@
|
|
1
|
-
require
|
1
|
+
require 'rubygems'
|
2
2
|
|
3
3
|
spec = Gem::Specification.new do |gem|
|
4
|
-
gem.name
|
5
|
-
gem.version
|
6
|
-
gem.authors
|
7
|
-
gem.
|
8
|
-
gem.
|
9
|
-
gem.
|
10
|
-
gem.
|
11
|
-
gem.
|
12
|
-
gem.test_files
|
13
|
-
gem.has_rdoc
|
14
|
-
gem.files
|
15
|
-
|
16
|
-
gem.
|
17
|
-
gem.extra_rdoc_files
|
18
|
-
|
19
|
-
gem.add_dependency(
|
20
|
-
gem.add_dependency(
|
21
|
-
gem.add_dependency(
|
22
|
-
gem.rubyforge_project = "win32utils"
|
23
|
-
end
|
4
|
+
gem.name = 'win32-file'
|
5
|
+
gem.version = '0.6.2'
|
6
|
+
gem.authors = ['Daniel J. Berger', 'Park Heesob']
|
7
|
+
gem.license = 'Artistic 2.0'
|
8
|
+
gem.email = 'djberg96@gmail.com'
|
9
|
+
gem.homepage = 'http://www.rubyforge.org/projects/win32utils'
|
10
|
+
gem.platform = Gem::Platform::RUBY
|
11
|
+
gem.summary = 'Extra or redefined methods for the File class on Windows.'
|
12
|
+
gem.test_files = Dir['test/test*']
|
13
|
+
gem.has_rdoc = true
|
14
|
+
gem.files = Dir['**/*'].reject{ |f| f.include?('CVS') }
|
15
|
+
|
16
|
+
gem.rubyforge_project = 'win32utils'
|
17
|
+
gem.extra_rdoc_files = ['README', 'CHANGES', 'MANIFEST']
|
18
|
+
|
19
|
+
gem.add_dependency('win32-api', '>= 1.4.4')
|
20
|
+
gem.add_dependency('win32-file-stat', '>= 1.3.2')
|
21
|
+
gem.add_dependency('windows-pr', '>= 1.0.6')
|
24
22
|
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
gem.add_development_dependency('test-unit', '>= 2.0.3')
|
24
|
+
|
25
|
+
gem.description = <<-EOF
|
26
|
+
The win32-file library adds several methods to the core File class which
|
27
|
+
are specific to MS Windows, such as the ability to set and retrieve file
|
28
|
+
attributes. In addition, several core methods have been redefined in
|
29
|
+
order to work properly on MS Windows, such as File.blksize. See the
|
30
|
+
README file for more details.
|
31
|
+
EOF
|
28
32
|
end
|
33
|
+
|
34
|
+
Gem::Builder.new(spec).build
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: win32-file
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel J. Berger
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-
|
13
|
+
date: 2009-08-21 00:00:00 -06:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
requirements:
|
22
22
|
- - ">="
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: 1.
|
24
|
+
version: 1.4.4
|
25
25
|
version:
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: win32-file-stat
|
@@ -34,26 +34,26 @@ dependencies:
|
|
34
34
|
version: 1.3.2
|
35
35
|
version:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
37
|
+
name: windows-pr
|
38
38
|
type: :runtime
|
39
39
|
version_requirement:
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
requirements:
|
42
42
|
- - ">="
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
version:
|
44
|
+
version: 1.0.6
|
45
45
|
version:
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
|
-
name:
|
48
|
-
type: :
|
47
|
+
name: test-unit
|
48
|
+
type: :development
|
49
49
|
version_requirement:
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: 2.0.3
|
55
55
|
version:
|
56
|
-
description:
|
56
|
+
description: " The win32-file library adds several methods to the core File class which\n are specific to MS Windows, such as the ability to set and retrieve file\n attributes. In addition, several core methods have been redefined in\n order to work properly on MS Windows, such as File.blksize. See the\n README file for more details.\n"
|
57
57
|
email: djberg96@gmail.com
|
58
58
|
executables: []
|
59
59
|
|
@@ -62,23 +62,24 @@ extensions: []
|
|
62
62
|
extra_rdoc_files:
|
63
63
|
- README
|
64
64
|
- CHANGES
|
65
|
+
- MANIFEST
|
65
66
|
files:
|
67
|
+
- CHANGES
|
66
68
|
- lib/win32/file.rb
|
69
|
+
- MANIFEST
|
70
|
+
- Rakefile
|
71
|
+
- README
|
67
72
|
- test/test_win32_file_attributes.rb
|
68
73
|
- test/test_win32_file_constants.rb
|
69
74
|
- test/test_win32_file_encryption.rb
|
70
75
|
- test/test_win32_file_path.rb
|
71
76
|
- test/test_win32_file_security.rb
|
72
77
|
- test/test_win32_file_stat.rb
|
73
|
-
- CHANGES
|
74
|
-
- lib
|
75
|
-
- MANIFEST
|
76
|
-
- Rakefile
|
77
|
-
- README
|
78
|
-
- test
|
79
78
|
- win32-file.gemspec
|
80
79
|
has_rdoc: true
|
81
80
|
homepage: http://www.rubyforge.org/projects/win32utils
|
81
|
+
licenses:
|
82
|
+
- Artistic 2.0
|
82
83
|
post_install_message:
|
83
84
|
rdoc_options: []
|
84
85
|
|
@@ -99,9 +100,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
100
|
requirements: []
|
100
101
|
|
101
102
|
rubyforge_project: win32utils
|
102
|
-
rubygems_version: 1.3.
|
103
|
+
rubygems_version: 1.3.5
|
103
104
|
signing_key:
|
104
|
-
specification_version:
|
105
|
+
specification_version: 3
|
105
106
|
summary: Extra or redefined methods for the File class on Windows.
|
106
107
|
test_files:
|
107
108
|
- test/test_win32_file_attributes.rb
|