win32-file-stat 1.2.7 → 1.2.8
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +6 -1
- data/MANIFEST +1 -1
- data/README +15 -12
- data/Rakefile +0 -2
- data/lib/win32/file/stat.rb +58 -45
- data/test/sometestfile.exe +0 -0
- data/test/{tc_file_stat.rb → test_file_stat.rb} +3 -3
- data/win32-file-stat.gemspec +5 -4
- metadata +53 -46
data/CHANGES
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
== 1.2.8 - 29-Jul-2008
|
2
|
+
* Internally now always uses wide character functions.
|
3
|
+
* A private alias was made private.
|
4
|
+
* Now requires windows-pr 0.9.1 or later.
|
5
|
+
|
1
6
|
== 1.2.7 - 1-Oct-2007
|
2
7
|
* Changed an error type in a private method in order to maintain
|
3
8
|
compatibility with the FileUtils module.
|
@@ -32,7 +37,7 @@
|
|
32
37
|
|
33
38
|
== 1.2.0 - 23-Apr-2006
|
34
39
|
* Removed the attribute setters. From now on this class provides readonly
|
35
|
-
methods. Use the win32-file
|
40
|
+
methods. Use the win32-file library for attribute setters.
|
36
41
|
* Added the content_indexed? alias for the indexed? method.
|
37
42
|
* Corresponding test suite changes.
|
38
43
|
* Fixed the pp issue by writing a custom pretty_print method.
|
data/MANIFEST
CHANGED
data/README
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
A redefinition of the File::Stat class for MS Windows.
|
3
3
|
|
4
4
|
= Prerequisites
|
5
|
-
* Ruby 1.8.
|
6
|
-
* windows-pr 0.
|
5
|
+
* Ruby 1.8.2 or later.
|
6
|
+
* windows-pr 0.9.1 or later.
|
7
7
|
|
8
8
|
= Installation
|
9
9
|
rake install (non-gem) OR rake install_gem (gems)
|
@@ -37,32 +37,35 @@ rake install (non-gem) OR rake install_gem (gems)
|
|
37
37
|
|
38
38
|
= Known issues
|
39
39
|
You should not require 'win32/file/stat' directly. Instead, require the
|
40
|
-
win32-file
|
40
|
+
win32-file library which will, in turn, require win32-file-stat. This is
|
41
41
|
the preferred approach because some modules (i.e. 'find') use the pass-through
|
42
42
|
methods of the File class, such as File.lstat. Many of the pass through
|
43
|
-
methods have been redefined in the win32-file
|
44
|
-
with the custom File::Stat objects created by this
|
43
|
+
methods have been redefined in the win32-file library to work in conjunction
|
44
|
+
with the custom File::Stat objects created by this library.
|
45
45
|
|
46
46
|
Failure to follow these instructions could lead to cases where the core Ruby
|
47
47
|
File class attempts to use the custom File::Stat object defined in this class,
|
48
|
-
|
48
|
+
and that will likely cause problems.
|
49
49
|
|
50
50
|
= Known bugs
|
51
|
-
None that I'm aware of
|
52
|
-
at
|
51
|
+
None that I'm aware of beyond the Known Issues listed above. Please report any
|
52
|
+
bugs you find on the project page at:
|
53
|
+
|
54
|
+
http://www.rubyforge.org/projects/win32utils.
|
53
55
|
|
54
56
|
= Miscellaneous
|
55
57
|
I had to require 'pp' explicitly in order to deal with the fact that pp.rb
|
56
|
-
has a builtin pretty_print method for File::Stat.
|
58
|
+
has a builtin pretty_print method for File::Stat. If I didn't do this
|
57
59
|
you would end up using the pretty_print in pp.rb, which would break.
|
58
60
|
|
59
61
|
= License
|
60
62
|
Ruby's
|
61
63
|
|
62
64
|
= Warranty
|
63
|
-
This
|
65
|
+
This library is provided "as is" and without any express or
|
64
66
|
implied warranties, including, without limitation, the implied
|
65
67
|
warranties of merchantability and fitness for a particular purpose.
|
66
68
|
|
67
|
-
=
|
68
|
-
Daniel J. Berger
|
69
|
+
= Authors
|
70
|
+
Daniel J. Berger
|
71
|
+
Park Heesob
|
data/Rakefile
CHANGED
data/lib/win32/file/stat.rb
CHANGED
@@ -21,7 +21,9 @@ class File::Stat
|
|
21
21
|
include Windows::Volume
|
22
22
|
include Comparable
|
23
23
|
|
24
|
-
VERSION = '1.2.
|
24
|
+
VERSION = '1.2.8'
|
25
|
+
|
26
|
+
private
|
25
27
|
|
26
28
|
# Defined in Ruby's win32.h. Not meant for public consumption.
|
27
29
|
S_IWGRP = 0020
|
@@ -39,6 +41,8 @@ class File::Stat
|
|
39
41
|
undef_method(:size, :size?, :socket?, :sticky?, :symlink?, :uid, :writable?)
|
40
42
|
undef_method(:writable_real?, :zero?)
|
41
43
|
undef_method(:pretty_print, :inspect, :<=>)
|
44
|
+
|
45
|
+
public
|
42
46
|
|
43
47
|
attr_reader :dev_major, :dev_minor, :rdev_major, :rdev_minor
|
44
48
|
|
@@ -48,12 +52,13 @@ class File::Stat
|
|
48
52
|
# the file after that point will not be reflected.
|
49
53
|
#
|
50
54
|
def initialize(file)
|
51
|
-
@file = file
|
55
|
+
@file = file.tr('/', "\\")
|
56
|
+
@file = multi_to_wide(@file)
|
52
57
|
|
53
|
-
@file_type = get_file_type(file)
|
58
|
+
@file_type = get_file_type(@file)
|
54
59
|
@chardev = @file_type == FILE_TYPE_CHAR
|
55
60
|
|
56
|
-
case
|
61
|
+
case GetDriveTypeW(@file)
|
57
62
|
when DRIVE_REMOVABLE, DRIVE_CDROM, DRIVE_RAMDISK
|
58
63
|
@blockdev = true
|
59
64
|
else
|
@@ -63,7 +68,7 @@ class File::Stat
|
|
63
68
|
stat_buf = [0,0,0,0,0,0,0,0,0,0,0,0,0].pack('ISSssssIIQQQQ')
|
64
69
|
|
65
70
|
# The stat64 function doesn't seem to like character devices
|
66
|
-
if
|
71
|
+
if wstat64(@file, stat_buf) != 0
|
67
72
|
raise ArgumentError, get_last_error unless @chardev
|
68
73
|
end
|
69
74
|
|
@@ -91,17 +96,17 @@ class File::Stat
|
|
91
96
|
|
92
97
|
@mode = 33188 if @chardev
|
93
98
|
|
94
|
-
|
95
|
-
error_num
|
99
|
+
attributes = GetFileAttributesW(@file)
|
100
|
+
error_num = GetLastError()
|
96
101
|
|
97
102
|
# Ignore errors caused by empty/open/used block devices.
|
98
|
-
if
|
103
|
+
if attributes == INVALID_FILE_ATTRIBUTES
|
99
104
|
unless error_num == ERROR_NOT_READY
|
100
105
|
raise ArgumentError, get_last_error(error_num)
|
101
106
|
end
|
102
107
|
end
|
103
108
|
|
104
|
-
@blksize = get_blksize(file)
|
109
|
+
@blksize = get_blksize(@file)
|
105
110
|
|
106
111
|
# This is a reasonable guess
|
107
112
|
case @blksize
|
@@ -113,21 +118,21 @@ class File::Stat
|
|
113
118
|
@blocks = (@size.to_f / @blksize.to_f).ceil
|
114
119
|
end
|
115
120
|
|
116
|
-
@readonly =
|
117
|
-
@hidden =
|
118
|
-
@system =
|
119
|
-
@archive =
|
120
|
-
@directory =
|
121
|
-
@encrypted =
|
122
|
-
@normal =
|
123
|
-
@temporary =
|
124
|
-
@sparse =
|
125
|
-
@reparse_point =
|
126
|
-
@compressed =
|
127
|
-
@offline =
|
128
|
-
@indexed =
|
121
|
+
@readonly = attributes & FILE_ATTRIBUTE_READONLY > 0
|
122
|
+
@hidden = attributes & FILE_ATTRIBUTE_HIDDEN > 0
|
123
|
+
@system = attributes & FILE_ATTRIBUTE_SYSTEM > 0
|
124
|
+
@archive = attributes & FILE_ATTRIBUTE_ARCHIVE > 0
|
125
|
+
@directory = attributes & FILE_ATTRIBUTE_DIRECTORY > 0
|
126
|
+
@encrypted = attributes & FILE_ATTRIBUTE_ENCRYPTED > 0
|
127
|
+
@normal = attributes & FILE_ATTRIBUTE_NORMAL > 0
|
128
|
+
@temporary = attributes & FILE_ATTRIBUTE_TEMPORARY > 0
|
129
|
+
@sparse = attributes & FILE_ATTRIBUTE_SPARSE_FILE > 0
|
130
|
+
@reparse_point = attributes & FILE_ATTRIBUTE_REPARSE_POINT > 0
|
131
|
+
@compressed = attributes & FILE_ATTRIBUTE_COMPRESSED > 0
|
132
|
+
@offline = attributes & FILE_ATTRIBUTE_OFFLINE > 0
|
133
|
+
@indexed = attributes & ~FILE_ATTRIBUTE_NOT_CONTENT_INDEXED > 0
|
129
134
|
|
130
|
-
@executable =
|
135
|
+
@executable = GetBinaryTypeW(@file, '')
|
131
136
|
@regular = @file_type == FILE_TYPE_DISK
|
132
137
|
@pipe = @file_type == FILE_TYPE_PIPE
|
133
138
|
|
@@ -539,7 +544,7 @@ class File::Stat
|
|
539
544
|
# If there's a drive letter it must contain a trailing backslash.
|
540
545
|
# The dup is necessary here because, for some odd reason, the function
|
541
546
|
# appears to modify the argument passed in.
|
542
|
-
if
|
547
|
+
if PathStripToRootW(file.dup)
|
543
548
|
file += "\\" unless file[-1].chr == "\\"
|
544
549
|
else
|
545
550
|
file = 0 # Default to root drive
|
@@ -556,34 +561,42 @@ class File::Stat
|
|
556
561
|
# Returns the file's type (as a numeric).
|
557
562
|
#
|
558
563
|
def get_file_type(file)
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
564
|
+
begin
|
565
|
+
handle = CreateFileW(
|
566
|
+
file,
|
567
|
+
GENERIC_READ,
|
568
|
+
FILE_SHARE_READ,
|
569
|
+
nil,
|
570
|
+
OPEN_EXISTING,
|
571
|
+
FILE_FLAG_BACKUP_SEMANTICS, # Need this for directories
|
572
|
+
nil
|
573
|
+
)
|
568
574
|
|
569
|
-
|
575
|
+
error_num = GetLastError()
|
570
576
|
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
+
# Ignore errors caused by open/empty/used block devices. We raise a
|
578
|
+
# SystemCallError explicitly here in order to maintain compatibility
|
579
|
+
# with the FileUtils module.
|
580
|
+
if handle == INVALID_HANDLE_VALUE
|
581
|
+
unless error_num == ERROR_NOT_READY
|
582
|
+
raise SystemCallError, get_last_error(error_num)
|
583
|
+
end
|
577
584
|
end
|
578
|
-
end
|
579
585
|
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
586
|
+
file_type = GetFileType(handle)
|
587
|
+
error_num = GetLastError()
|
588
|
+
ensure
|
589
|
+
CloseHandle(handle)
|
590
|
+
end
|
591
|
+
|
592
|
+
if file_type == FILE_TYPE_UNKNOWN && error_num != NO_ERROR
|
593
|
+
raise SystemCallError, get_last_error(error_num)
|
594
|
+
end
|
584
595
|
|
585
596
|
file_type
|
586
597
|
end
|
598
|
+
|
599
|
+
private
|
587
600
|
|
588
601
|
# Verifies that a value is either true or false
|
589
602
|
def check_bool(val)
|
data/test/sometestfile.exe
CHANGED
File without changes
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#####################################################################
|
2
|
-
#
|
2
|
+
# test_file_stat.rb
|
3
3
|
#
|
4
4
|
# Test case for stat related methods of win32-file. You should use
|
5
5
|
# the 'rake test' task to run these tests.
|
@@ -30,14 +30,14 @@ class TC_Win32_File_Stat < Test::Unit::TestCase
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_version
|
33
|
-
assert_equal('1.2.
|
33
|
+
assert_equal('1.2.8', File::Stat::VERSION)
|
34
34
|
end
|
35
35
|
|
36
36
|
# One or more tests will fail if the archive attribute on @file is not set.
|
37
37
|
def test_archive
|
38
38
|
assert_respond_to(@stat, :archive?)
|
39
39
|
assert_nothing_raised{ @stat.archive? }
|
40
|
-
assert(@stat.archive?, '
|
40
|
+
assert(@stat.archive?, '=> May fail - ignore')
|
41
41
|
end
|
42
42
|
|
43
43
|
def test_atime
|
data/win32-file-stat.gemspec
CHANGED
@@ -2,20 +2,21 @@ require "rubygems"
|
|
2
2
|
|
3
3
|
spec = Gem::Specification.new do |gem|
|
4
4
|
gem.name = "win32-file-stat"
|
5
|
-
gem.version = "1.2.
|
6
|
-
gem.
|
5
|
+
gem.version = "1.2.8"
|
6
|
+
gem.authors = ["Daniel J. Berger", "Park Heesob"]
|
7
7
|
gem.email = "djberg96@gmail.com"
|
8
8
|
gem.homepage = "http://www.rubyforge.org/projects/win32utils"
|
9
9
|
gem.platform = Gem::Platform::RUBY
|
10
10
|
gem.summary = "A File::Stat class tailored to MS Windows"
|
11
11
|
gem.description = "A File::Stat class tailored to MS Windows"
|
12
|
-
gem.test_file = "test/
|
12
|
+
gem.test_file = "test/test_file_stat.rb"
|
13
13
|
gem.has_rdoc = true
|
14
14
|
gem.files = Dir['lib/win32/file/*.rb'] + Dir['[A-Z]*'] + Dir['test/*']
|
15
15
|
gem.files.reject! { |fn| fn.include? "CVS" }
|
16
16
|
gem.require_path = "lib"
|
17
17
|
gem.extra_rdoc_files = ["README", "CHANGES"]
|
18
|
-
gem.add_dependency("windows-pr", ">= 0.
|
18
|
+
gem.add_dependency("windows-pr", ">= 0.9.1")
|
19
|
+
gem.rubyforge_project = 'Win32Utils'
|
19
20
|
end
|
20
21
|
|
21
22
|
if $0 == __FILE__
|
metadata
CHANGED
@@ -1,67 +1,74 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.4
|
3
|
-
specification_version: 1
|
4
2
|
name: win32-file-stat
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.2.
|
7
|
-
date: 2007-10-01 00:00:00 -06:00
|
8
|
-
summary: A File::Stat class tailored to MS Windows
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: djberg96@gmail.com
|
12
|
-
homepage: http://www.rubyforge.org/projects/win32utils
|
13
|
-
rubyforge_project:
|
14
|
-
description: A File::Stat class tailored to MS Windows
|
15
|
-
autorequire:
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 1.2.8
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
7
|
- Daniel J. Berger
|
8
|
+
- Park Heesob
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2008-07-29 00:00:00 -06:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: windows-pr
|
18
|
+
type: :runtime
|
19
|
+
version_requirement:
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 0.9.1
|
25
|
+
version:
|
26
|
+
description: A File::Stat class tailored to MS Windows
|
27
|
+
email: djberg96@gmail.com
|
28
|
+
executables: []
|
29
|
+
|
30
|
+
extensions: []
|
31
|
+
|
32
|
+
extra_rdoc_files:
|
33
|
+
- README
|
34
|
+
- CHANGES
|
31
35
|
files:
|
32
36
|
- lib/win32/file/stat.rb
|
33
37
|
- CHANGES
|
34
|
-
- CVS
|
35
38
|
- lib
|
36
39
|
- MANIFEST
|
37
40
|
- Rakefile
|
38
41
|
- README
|
39
42
|
- test
|
40
43
|
- win32-file-stat.gemspec
|
41
|
-
- test/CVS
|
42
44
|
- test/sometestfile.exe
|
43
45
|
- test/sometestfile.txt
|
44
|
-
- test/
|
45
|
-
|
46
|
-
|
46
|
+
- test/test_file_stat.rb
|
47
|
+
has_rdoc: true
|
48
|
+
homepage: http://www.rubyforge.org/projects/win32utils
|
49
|
+
post_install_message:
|
47
50
|
rdoc_options: []
|
48
51
|
|
49
|
-
|
50
|
-
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: "0"
|
59
|
+
version:
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: "0"
|
65
|
+
version:
|
56
66
|
requirements: []
|
57
67
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: 0.6.0
|
67
|
-
version:
|
68
|
+
rubyforge_project: Win32Utils
|
69
|
+
rubygems_version: 1.2.0
|
70
|
+
signing_key:
|
71
|
+
specification_version: 2
|
72
|
+
summary: A File::Stat class tailored to MS Windows
|
73
|
+
test_files:
|
74
|
+
- test/test_file_stat.rb
|