win32-file-stat 1.3.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,10 @@
1
+ == 1.3.3 - 9-Feb-2009
2
+ * Fixed a bug where File::Stat.new failed on locked files. Thanks go to
3
+ Montgomery Kosma for the spot.
4
+ * Now requires windows-pr 1.0.0 or later.
5
+ * Updated the README to note that 32 bit versions of Ruby which attempt
6
+ to access locked system files on 64 bit versions of MS Windows will fail.
7
+
1
8
  == 1.3.2 - 1-Oct-2008
2
9
  * Fixed an issue with the private get_blksize method.
3
10
  * Updated the test suite to use Test::Unit 2.x, which also makes it a
data/README CHANGED
@@ -6,6 +6,10 @@ A redefinition of the File::Stat class for MS Windows.
6
6
  * windows-pr 0.9.1 or later.
7
7
 
8
8
  = Installation
9
+ == Remote Installation
10
+ gem install win32-file-stat
11
+
12
+ == Local Installation
9
13
  rake install (non-gem) OR rake install_gem (gems)
10
14
 
11
15
  = Synopsis
@@ -47,6 +51,9 @@ Failure to follow these instructions could lead to cases where the core Ruby
47
51
  File class attempts to use the custom File::Stat object defined in this class,
48
52
  and that will likely cause problems.
49
53
 
54
+ Also, a 32 bit Ruby attempting to access a locked system file on a 64 bit
55
+ version of MS Windows will fail.
56
+
50
57
  = Known bugs
51
58
  None that I'm aware of beyond the Known Issues listed above. Please report any
52
59
  bugs you find on the project page at:
data/Rakefile CHANGED
@@ -3,19 +3,15 @@ require 'rake/testtask'
3
3
  require 'rbconfig'
4
4
  include Config
5
5
 
6
- desc 'Install the win32-file-stat package (non-gem)'
6
+ desc 'Install the win32-file-stat library (non-gem)'
7
7
  task :install do
8
- sitelibdir = CONFIG['sitelibdir']
9
- installdir = sitelibdir + '/win32/file'
10
- basedir = File.dirname(installdir)
8
+ install_dir = File.join(CONFIG['sitelibdir'], 'win32', 'file')
11
9
  file = 'lib\win32\file\stat.rb'
12
-
13
- Dir.mkdir(basedir) unless File.exists?(basedir)
14
- Dir.mkdir(installdir) unless File.exists?(installdir)
15
- FileUtils.cp(file, installdir, :verbose => true)
10
+ FileUtils.mkdir_p(install_dir)
11
+ FileUtils.cp(file, install_dir, :verbose => true)
16
12
  end
17
13
 
18
- desc 'Install the win32-file-stat package as a gem'
14
+ desc 'Install the win32-file-stat library as a gem'
19
15
  task :install_gem do
20
16
  ruby 'win32-file-stat.gemspec'
21
17
  file = Dir["win32-file-stat*.gem"].first
@@ -7,6 +7,10 @@ require 'windows/file'
7
7
  require 'windows/error'
8
8
  require 'windows/handle'
9
9
  require 'windows/volume'
10
+ require 'windows/process'
11
+ require 'windows/security'
12
+ require 'windows/time'
13
+ require 'windows/ntfs/winternl'
10
14
  require 'pp'
11
15
 
12
16
  class File::Stat
@@ -19,9 +23,14 @@ class File::Stat
19
23
  include Windows::Error
20
24
  include Windows::Handle
21
25
  include Windows::Volume
26
+ include Windows::Process
27
+ include Windows::Security
28
+ include Windows::Time
29
+ include Windows::NTFS::Winternl
22
30
  include Comparable
23
31
 
24
- VERSION = '1.3.2'
32
+ # The version of this library
33
+ VERSION = '1.3.3'
25
34
 
26
35
  private
27
36
 
@@ -33,7 +42,7 @@ class File::Stat
33
42
  # it later, after we've defined our initialize method.
34
43
  alias old_init initialize # :nodoc:
35
44
 
36
- # Make this package -w clean
45
+ # Make this library -w clean
37
46
  undef_method(:atime, :blksize, :blockdev?, :blocks, :chardev?, :ctime)
38
47
  undef_method(:dev, :directory?, :executable?, :file?, :ftype, :gid, :ino)
39
48
  undef_method(:executable_real?, :grpowned?, :mode, :mtime, :nlink, :owned?)
@@ -52,9 +61,10 @@ class File::Stat
52
61
  # the file after that point will not be reflected.
53
62
  #
54
63
  def initialize(file)
55
- @file = file.tr('/', "\\")
64
+ @file = File.expand_path(file)
65
+ @file = @file.tr('/', "\\")
56
66
  @file = multi_to_wide(@file)
57
-
67
+
58
68
  @file_type = get_file_type(@file)
59
69
  @chardev = @file_type == FILE_TYPE_CHAR
60
70
 
@@ -64,13 +74,13 @@ class File::Stat
64
74
  else
65
75
  @blockdev = false
66
76
  end
67
-
77
+
68
78
  # The stat struct in stat.h only has 11 members on Windows
69
79
  stat_buf = [0,0,0,0,0,0,0,0,0,0,0].pack('ISSsssIQQQQ')
70
-
80
+
71
81
  # The stat64 function doesn't seem to like character devices
72
82
  if wstat64(@file, stat_buf) != 0
73
- raise ArgumentError, get_last_error unless @chardev
83
+ raise ArgumentError, get_last_error unless @chardev
74
84
  end
75
85
 
76
86
  # Some bytes skipped (padding for struct alignment)
@@ -99,15 +109,46 @@ class File::Stat
99
109
 
100
110
  attributes = GetFileAttributesW(@file)
101
111
  error_num = GetLastError()
102
-
112
+
113
+ # Locked files.
114
+ if error_num == ERROR_SHARING_VIOLATION
115
+ buffer = 0.chr * 512
116
+
117
+ begin
118
+ handle = FindFirstFileW(@file, buffer)
119
+
120
+ if handle == INVALID_HANDLE_VALUE
121
+ raise SystemCallError, get_last_error()
122
+ end
123
+ ensure
124
+ FindClose(handle) if handle != INVALID_HANDLE_VALUE
125
+ end
126
+
127
+ attributes = buffer[0,4].unpack('L').first
128
+ st = 0.chr * 16
129
+ FileTimeToSystemTime(buffer[4,8],st)
130
+ y,m,w,d,h,n,s,i = st.unpack('SSSSSSSS')
131
+ @ctime = Time.local(y,m,d,h,n,s)
132
+
133
+ st = 0.chr * 16
134
+ FileTimeToSystemTime(buffer[12,8],st)
135
+ y,m,w,d,h,n,s,i = st.unpack('SSSSSSSS')
136
+ @atime = Time.local(y,m,d,h,n,s)
137
+
138
+ st = 0.chr * 16
139
+ FileTimeToSystemTime(buffer[20,8],st)
140
+ y,m,w,d,h,n,s,i = st.unpack('SSSSSSSS')
141
+ @mtime = Time.local(y,m,d,h,n,s)
142
+ end
143
+
103
144
  # Ignore errors caused by empty/open/used block devices.
104
145
  if attributes == INVALID_FILE_ATTRIBUTES
105
146
  unless error_num == ERROR_NOT_READY
106
147
  raise ArgumentError, get_last_error(error_num)
107
148
  end
108
149
  end
109
-
110
- @blksize = get_blksize(@file)
150
+
151
+ @blksize = get_blksize(@file)
111
152
 
112
153
  # This is a reasonable guess
113
154
  case @blksize
@@ -563,6 +604,81 @@ class File::Stat
563
604
  size
564
605
  end
565
606
 
607
+ # Private method to get a HANDLE when CreateFile() won't cut it.
608
+ #
609
+ def get_handle(file)
610
+ file = file.upcase
611
+
612
+ begin
613
+ hdlTokenHandle = 0.chr * 4
614
+
615
+ OpenProcessToken(
616
+ GetCurrentProcess(),
617
+ TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
618
+ hdlTokenHandle
619
+ )
620
+
621
+ hdlTokenHandle = hdlTokenHandle.unpack('L').first
622
+
623
+ # Get the LUID for shutdown privilege.
624
+ tmpLuid = 0.chr * 8
625
+ LookupPrivilegeValue("", "SeDebugPrivilege", tmpLuid)
626
+ tkp = [1].pack('L') + tmpLuid + [SE_PRIVILEGE_ENABLED].pack('L')
627
+
628
+ # Enable the shutdown privilege in the access token of this process.
629
+ AdjustTokenPrivileges(hdlTokenHandle, 0,tkp, tkp.length , nil, nil)
630
+ ensure
631
+ CloseHandle(hdlTokenHandle)
632
+ end
633
+
634
+ # First call is to get the required length
635
+ handle_info = 0.chr * 4096
636
+ required = 0.chr * 4
637
+ NtQuerySystemInformation(16, handle_info, 4096, required)
638
+
639
+ # Second call is the actual call
640
+ handle_info = 0.chr * required.unpack('L').first
641
+ NtQuerySystemInformation(16, handle_info, handle_info.length, required)
642
+
643
+ count = handle_info[0,4].unpack('L').first
644
+
645
+ for i in 0...count
646
+ pid, type, handle, addr, access = handle_info[4+i*16,16].unpack('LSSLL')
647
+ if access & 0xffff == 3
648
+ begin
649
+ process = OpenProcess(0x40,1,pid)
650
+ dup_handle = 0.chr * 4
651
+
652
+ DuplicateHandle(
653
+ process,
654
+ handle,
655
+ GetCurrentProcess(),
656
+ dup_handle,
657
+ 0,
658
+ 1,
659
+ 2
660
+ )
661
+ ensure
662
+ CloseHandle(process)
663
+ end
664
+
665
+ handle = dup_handle.unpack('L').first
666
+ buffer = 0.chr * 0x2000
667
+ NtQueryObject(handle, 1, buffer, 0x2000, nil)
668
+ len = buffer[0,2].unpack('S').first
669
+
670
+ if len>0
671
+ if buffer[8..-1].upcase[file]
672
+ return handle
673
+ end
674
+ end
675
+ CloseHandle(handle)
676
+ end
677
+ end
678
+
679
+ return 0
680
+ end
681
+
566
682
  # Returns the file's type (as a numeric).
567
683
  #
568
684
  def get_file_type(file)
@@ -578,10 +694,18 @@ class File::Stat
578
694
  )
579
695
 
580
696
  error_num = GetLastError()
581
-
582
- # Ignore errors caused by open/empty/used block devices. We raise a
583
- # SystemCallError explicitly here in order to maintain compatibility
584
- # with the FileUtils module.
697
+
698
+ # CreateFile() chokes on locked files
699
+ if error_num == ERROR_SHARING_VIOLATION
700
+ drive = file[0,4] + 0.chr * 2
701
+ device = 0.chr * 512
702
+ QueryDosDeviceW(drive, device, 256)
703
+ file = device.strip + 0.chr + file[4..-1]
704
+ handle = get_handle(file)
705
+ end
706
+
707
+ # We raise a SystemCallError explicitly here in order to maintain
708
+ # compatibility with the FileUtils module.
585
709
  if handle == INVALID_HANDLE_VALUE
586
710
  raise SystemCallError, get_last_error(error_num)
587
711
  end
@@ -605,4 +729,4 @@ class File::Stat
605
729
  def check_bool(val)
606
730
  raise TypeError unless val == true || val == false
607
731
  end
608
- end
732
+ end
@@ -35,11 +35,12 @@ class TC_Win32_File_Stat < Test::Unit::TestCase
35
35
  def setup
36
36
  @dir = Dir.pwd
37
37
  @stat = File::Stat.new(@@txt_file)
38
- @attr = GetFileAttributes(@@txt_file)
38
+ @attr = GetFileAttributes(@@txt_file)
39
+ @sys = 'C:/pagefile.sys'
39
40
  end
40
41
 
41
42
  def test_version
42
- assert_equal('1.3.2', File::Stat::VERSION)
43
+ assert_equal('1.3.3', File::Stat::VERSION)
43
44
  end
44
45
 
45
46
  # One or more tests will fail if the archive attribute on @@text_file
@@ -268,6 +269,10 @@ class TC_Win32_File_Stat < Test::Unit::TestCase
268
269
  assert_equal(21, @stat.size)
269
270
  end
270
271
 
272
+ def test_size_system_file
273
+ assert_nothing_raised{ File::Stat.new(@sys).size }
274
+ end
275
+
271
276
  def test_size_bool
272
277
  assert_respond_to(@stat, :size?)
273
278
  assert_equal(21, @stat.size?)
@@ -2,7 +2,7 @@ require "rubygems"
2
2
 
3
3
  spec = Gem::Specification.new do |gem|
4
4
  gem.name = "win32-file-stat"
5
- gem.version = "1.3.2"
5
+ gem.version = "1.3.3"
6
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"
@@ -15,12 +15,12 @@ spec = Gem::Specification.new do |gem|
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.9.1")
19
- gem.add_dependency("test-unit", ">= 2.0.0")
18
+ gem.add_dependency("windows-pr", ">= 1.0.0")
19
+ gem.add_dependency("test-unit", ">= 2.0.2")
20
20
  gem.rubyforge_project = 'Win32Utils'
21
21
  end
22
22
 
23
23
  if $0 == __FILE__
24
- Gem.manage_gems
24
+ Gem.manage_gems if Gem::RubyGemsVersion.to_f < 1.0
25
25
  Gem::Builder.new(spec).build
26
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: win32-file-stat
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
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: 2008-10-01 00:00:00 -06:00
13
+ date: 2009-02-09 00:00:00 -07: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: 0.9.1
24
+ version: 1.0.0
25
25
  version:
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: test-unit
@@ -31,7 +31,7 @@ dependencies:
31
31
  requirements:
32
32
  - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: 2.0.0
34
+ version: 2.0.2
35
35
  version:
36
36
  description: A File::Stat class tailored to MS Windows
37
37
  email: djberg96@gmail.com
@@ -52,7 +52,6 @@ files:
52
52
  - test
53
53
  - win32-file-stat.gemspec
54
54
  - test/test_file_stat.rb
55
- - test/test_file_stat.rb~
56
55
  has_rdoc: true
57
56
  homepage: http://www.rubyforge.org/projects/win32utils
58
57
  post_install_message:
@@ -75,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
74
  requirements: []
76
75
 
77
76
  rubyforge_project: Win32Utils
78
- rubygems_version: 1.3.0
77
+ rubygems_version: 1.3.1
79
78
  signing_key:
80
79
  specification_version: 2
81
80
  summary: A File::Stat class tailored to MS Windows
@@ -1,343 +0,0 @@
1
- #####################################################################
2
- # test_file_stat.rb
3
- #
4
- # Test case for stat related methods of win32-file. You should use
5
- # the 'rake test' task to run these tests.
6
- #####################################################################
7
- require 'rubygems'
8
- gem 'test-unit'
9
- require 'test/unit'
10
- require 'win32/file/stat'
11
- include Windows::Volume
12
-
13
- class TC_Win32_File_Stat < Test::Unit::TestCase
14
- include Windows::File
15
-
16
- def self.startup
17
- Dir.chdir('test') unless File.basename(Dir.pwd) == 'test'
18
-
19
- 'A'.upto('Z'){ |volume|
20
- volume += ":\\"
21
- case GetDriveType(volume)
22
- when DRIVE_REMOVABLE, DRIVE_CDROM, DRIVE_RAMDISK
23
- @@block_dev = volume
24
- break
25
- end
26
- }
27
-
28
- @@txt_file = 'test_file.txt'
29
- @@exe_file = 'test_file.exe'
30
-
31
- File.open(@@txt_file, "w"){ |fh| fh.print "This is a test\nHello" }
32
- File.open(@@exe_file, "wb"){ |fh| fh.print "This is a test" }
33
- end
34
-
35
- def setup
36
- @dir = Dir.pwd
37
- @stat = File::Stat.new(@@txt_file)
38
- @attr = GetFileAttributes(@@txt_file)
39
- end
40
-
41
- def test_version
42
- assert_equal('1.3.3', File::Stat::VERSION)
43
- end
44
-
45
- # One or more tests will fail if the archive attribute on @@text_file
46
- # is not set.
47
- def test_archive
48
- assert_respond_to(@stat, :archive?)
49
- assert_nothing_raised{ @stat.archive? }
50
- assert(@stat.archive?, '=> May fail - ignore')
51
- end
52
-
53
- def test_atime
54
- assert_respond_to(@stat, :atime)
55
- assert_kind_of(Time, @stat.atime)
56
- end
57
-
58
- def test_blksize
59
- assert_respond_to(@stat, :blksize)
60
- assert_equal(4096, @stat.blksize)
61
- assert_equal(4096, File::Stat.new("C:\\").blksize)
62
- end
63
-
64
- # The block dev test error out if there's no media in it.
65
- def test_blockdev
66
- assert_respond_to(@stat, :blockdev?)
67
- assert_equal(false, @stat.blockdev?)
68
- assert_equal(false, File::Stat.new('NUL').blockdev?)
69
-
70
- begin
71
- assert_equal(true, File::Stat.new(@@block_dev).blockdev?)
72
- rescue SystemCallError
73
- omit("Skipping because drive is empty")
74
- end
75
- end
76
-
77
- def test_blocks
78
- assert_respond_to(@stat, :blocks)
79
- assert_equal(1, @stat.blocks)
80
- end
81
-
82
- def test_chardev
83
- assert_respond_to(@stat, :chardev?)
84
- assert_nothing_raised{ File::Stat.new("NUL").chardev? }
85
- assert_equal(true, File::Stat.new("NUL").chardev?)
86
- assert_equal(false, File::Stat.new("C:\\").chardev?)
87
- end
88
-
89
- def test_comparison
90
- assert_respond_to(@stat, :<=>)
91
- assert_nothing_raised{ @stat <=> File::Stat.new(@@exe_file) }
92
- end
93
-
94
- def test_compressed
95
- assert_respond_to(@stat, :compressed?)
96
- assert_nothing_raised{ @stat.compressed? }
97
- assert_equal(false, @stat.compressed?)
98
- end
99
-
100
- def test_ctime
101
- assert_respond_to(@stat, :ctime)
102
- assert_kind_of(Time, @stat.ctime)
103
- end
104
-
105
- # Assumes you've installed on C: drive.
106
- def test_dev
107
- assert_respond_to(@stat, :dev)
108
- assert_equal('C:', @stat.dev)
109
- end
110
-
111
- def test_dev_major
112
- assert_respond_to(@stat, :dev_major)
113
- assert_nil(@stat.dev_major)
114
- end
115
-
116
- def test_dev_minor
117
- assert_respond_to(@stat, :dev_minor)
118
- assert_nil(@stat.dev_minor)
119
- end
120
-
121
- def test_directory
122
- assert_respond_to(@stat, :directory?)
123
- assert_equal(false, @stat.directory?)
124
- assert_equal(true, File::Stat.new("C:\\").directory?)
125
- end
126
-
127
- def test_executable
128
- assert_respond_to(@stat, :executable?)
129
- assert_equal(false, @stat.executable?)
130
- assert_equal(true, File::Stat.new(@@exe_file).executable?)
131
- end
132
-
133
- def test_executable_real
134
- assert_respond_to(@stat, :executable_real?)
135
- assert_equal(false, @stat.executable_real?)
136
- assert_equal(true, File::Stat.new(@@exe_file).executable_real?)
137
- end
138
-
139
- def test_file
140
- assert_respond_to(@stat, :file?)
141
- assert_equal(true, @stat.file?)
142
- assert_equal(true, File::Stat.new(@@exe_file).file?)
143
- assert_equal(true, File::Stat.new(Dir.pwd).file?)
144
- assert_equal(false, File::Stat.new('NUL').file?)
145
- end
146
-
147
- def test_ftype
148
- assert_respond_to(@stat, :ftype)
149
- assert_equal('file', @stat.ftype)
150
- assert_equal('characterSpecial', File::Stat.new('NUL').ftype)
151
- assert_equal('directory', File::Stat.new(Dir.pwd).ftype)
152
- end
153
-
154
- def encrypted
155
- assert_respond_to(@stat, :encrypted?)
156
- assert_nothing_raised{ @stat.encrypted? }
157
- end
158
-
159
- def test_gid
160
- assert_respond_to(@stat, :gid)
161
- assert_equal(0, @stat.gid)
162
- end
163
-
164
- def test_grpowned
165
- assert_respond_to(@stat, :grpowned?)
166
- end
167
-
168
- def test_hidden
169
- assert_respond_to(@stat, :hidden?)
170
- assert_nothing_raised{ @stat.hidden? }
171
- assert_equal(false, @stat.hidden?)
172
- end
173
-
174
- def test_indexed
175
- assert_respond_to(@stat, :indexed?)
176
- assert_respond_to(@stat, :content_indexed?) # alias
177
- assert_nothing_raised{ @stat.indexed? }
178
- assert(@stat.indexed?)
179
- end
180
-
181
- def test_ino
182
- assert_respond_to(@stat, :ino)
183
- assert_equal(0, @stat.ino)
184
- end
185
-
186
- def test_inspect
187
- assert_respond_to(@stat, :inspect)
188
- end
189
-
190
- def test_mode
191
- assert_respond_to(@stat, :mode)
192
- assert_equal(33188, File::Stat.new(@@txt_file).mode)
193
- assert_equal(33261, File::Stat.new(@@exe_file).mode)
194
- assert_equal(16877, File::Stat.new(@dir).mode)
195
-
196
- SetFileAttributes(@@txt_file, 1) # Set to readonly.
197
- assert_equal(33060, File::Stat.new(@@txt_file).mode)
198
- end
199
-
200
- def test_mtime
201
- assert_respond_to(@stat, :mtime)
202
- assert_kind_of(Time, @stat.mtime)
203
- end
204
-
205
- def test_nlink
206
- assert_respond_to(@stat, :nlink)
207
- assert_equal(1, @stat.nlink)
208
- end
209
-
210
- def test_normal
211
- assert_respond_to(@stat, :normal?)
212
- assert_nothing_raised{ @stat.normal? }
213
- assert_equal(false, @stat.normal?)
214
- end
215
-
216
- def test_offline
217
- assert_respond_to(@stat, :offline?)
218
- assert_nothing_raised{ @stat.offline? }
219
- assert_equal(false, @stat.offline?)
220
- end
221
-
222
- def test_pipe
223
- assert_respond_to(@stat, :pipe?)
224
- assert_equal(false, @stat.pipe?)
225
- end
226
-
227
- def test_readable
228
- assert_respond_to(@stat, :readable?)
229
- assert_equal(true, @stat.readable?)
230
- end
231
-
232
- def test_readable_real
233
- assert_respond_to(@stat, :readable_real?)
234
- assert_equal(true, @stat.readable_real?)
235
- end
236
-
237
- def test_readonly
238
- assert_respond_to(@stat, :readonly?)
239
- assert_nothing_raised{ @stat.readonly? }
240
- assert_equal(false, @stat.readonly?)
241
- end
242
-
243
- def test_reparse_point
244
- assert_respond_to(@stat, :reparse_point?)
245
- assert_nothing_raised{ @stat.reparse_point? }
246
- assert_equal(false, @stat.reparse_point?)
247
- end
248
-
249
- # Assumes you've installed on C: drive.
250
- def test_rdev
251
- msg = "ignore failure if Ruby is not installed on C: drive"
252
- assert_respond_to(@stat, :rdev)
253
- assert_equal(2, @stat.rdev, msg)
254
- end
255
-
256
- def test_setgid
257
- assert_respond_to(@stat, :setgid?)
258
- assert_equal(false, @stat.setgid?)
259
- end
260
-
261
- def test_setuid
262
- assert_respond_to(@stat, :setuid?)
263
- assert_equal(false, @stat.setuid?)
264
- end
265
-
266
- def test_size
267
- assert_respond_to(@stat, :size)
268
- assert_equal(21, @stat.size)
269
- end
270
-
271
- def test_size_bool
272
- assert_respond_to(@stat, :size?)
273
- assert_equal(21, @stat.size?)
274
- end
275
-
276
- def test_socket
277
- assert_respond_to(@stat, :socket?)
278
- assert_equal(false, @stat.socket?)
279
- end
280
-
281
- def test_sparse
282
- assert_respond_to(@stat, :sparse?)
283
- assert_nothing_raised{ @stat.sparse? }
284
- assert_equal(false, @stat.sparse?)
285
- end
286
-
287
- def test_sticky
288
- assert_respond_to(@stat, :sticky?)
289
- assert_equal(false, @stat.sticky?)
290
- end
291
-
292
- def test_symlink
293
- assert_respond_to(@stat, :symlink?)
294
- assert_equal(false, @stat.symlink?)
295
- end
296
-
297
- def test_system
298
- assert_respond_to(@stat, :system?)
299
- assert_nothing_raised{ @stat.system? }
300
- assert_equal(false, @stat.system?)
301
- end
302
-
303
- def test_temporary
304
- assert_respond_to(@stat, :temporary?)
305
- assert_nothing_raised{ @stat.temporary? }
306
- assert_equal(false, @stat.temporary?)
307
- end
308
-
309
- def test_uid
310
- assert_respond_to(@stat, :uid)
311
- assert_equal(0, @stat.uid)
312
- end
313
-
314
- def test_writable
315
- assert_respond_to(@stat, :writable?)
316
- assert_equal(true, @stat.writable?)
317
- end
318
-
319
- def test_writable_real
320
- assert_respond_to(@stat, :writable_real?)
321
- assert_equal(true, @stat.writable_real?)
322
- end
323
-
324
- def test_zero
325
- assert_respond_to(@stat, :zero?)
326
- assert_equal(false, @stat.zero?)
327
- end
328
-
329
- def teardown
330
- SetFileAttributes(@@txt_file, @attr) # Set file back to normal
331
- @dir = nil
332
- @stat = nil
333
- @attr = nil
334
- end
335
-
336
- def self.shutdown
337
- File.delete(@@txt_file) if File.exists?(@@txt_file)
338
- File.delete(@@exe_file) if File.exists?(@@exe_file)
339
- @@block_dev = nil
340
- @@txt_file = nil
341
- @@exe_file = nil
342
- end
343
- end