win32-file-stat 1.3.5 → 1.3.6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,6 @@
1
+ == 1.3.6 - 24-Mar-2012
2
+ * Eliminated some warnings for Ruby 1.9.3.
3
+
1
4
  == 1.3.5 - 21-Nov-2011
2
5
  * Fixed a bug in the dev method for 1.9.x.
3
6
  * Fixed some method redefinition warnings.
data/README CHANGED
@@ -2,7 +2,6 @@
2
2
  A redefinition of the File::Stat class for MS Windows.
3
3
 
4
4
  == Prerequisites
5
- * Ruby 1.8.2 or later.
6
5
  * windows-pr 0.9.1 or later.
7
6
 
8
7
  == Installation
@@ -70,7 +69,7 @@ This library will eventually be merged with the win32-file library. It will
70
69
  also be refactored to use FindFirstFile().
71
70
 
72
71
  == Copyright
73
- (C) 2003-2009, Daniel J. Berger, All Rights Reserved.
72
+ (C) 2003-2012, Daniel J. Berger, All Rights Reserved.
74
73
 
75
74
  == License
76
75
  Artistic 2.0
@@ -28,22 +28,22 @@ class File::Stat
28
28
  include Windows::Time
29
29
  include Windows::NTFS::Winternl
30
30
  include Comparable
31
-
31
+
32
32
  # The version of the win32-file-stat library
33
- VERSION = '1.3.5'
33
+ VERSION = '1.3.6'
34
34
 
35
35
  private
36
-
37
- # :stopdoc:
36
+
37
+ # :stopdoc:
38
38
 
39
39
  # Defined in Ruby's win32.h. Not meant for public consumption.
40
40
  S_IWGRP = 0020
41
41
  S_IWOTH = 0002
42
-
42
+
43
43
  # This is the only way to avoid a -w warning for initialize. We remove
44
44
  # it later, after we've defined our initialize method.
45
45
  alias old_init initialize
46
-
46
+
47
47
  # Make this library -w clean
48
48
  undef_method(:atime, :blksize, :blockdev?, :blocks, :chardev?, :ctime)
49
49
  undef_method(:dev, :directory?, :executable?, :file?, :ftype, :gid, :ino)
@@ -53,7 +53,7 @@ class File::Stat
53
53
  undef_method(:dev_major, :dev_minor, :rdev_major, :rdev_minor)
54
54
  undef_method(:writable_real?, :zero?)
55
55
  undef_method(:pretty_print, :inspect, :<=>)
56
-
56
+
57
57
  public
58
58
 
59
59
  # Always nil. Provided for interface compatibility only.
@@ -61,9 +61,9 @@ class File::Stat
61
61
  attr_reader :dev_minor
62
62
  attr_reader :rdev_major
63
63
  attr_reader :rdev_minor
64
-
64
+
65
65
  # :startdoc:
66
-
66
+
67
67
  # Creates and returns a File::Stat object, which encapsulate common status
68
68
  # information for File objects on MS Windows sytems. The information is
69
69
  # recorded at the moment the File::Stat object is created; changes made to
@@ -83,7 +83,7 @@ class File::Stat
83
83
  else
84
84
  @blockdev = false
85
85
  end
86
-
86
+
87
87
  # The stat struct in stat.h only has 11 members on Windows
88
88
  stat_buf = [0,0,0,0,0,0,0,0,0,0,0].pack('ISSsssIQQQQ')
89
89
 
@@ -101,7 +101,7 @@ class File::Stat
101
101
  @gid = stat_buf[12, 2].unpack('s').first # Always 0
102
102
  @rdev = stat_buf[16, 4].unpack('I').first # Same as dev
103
103
  @size = stat_buf[24, 8].unpack('Q').first # Size of file in bytes
104
-
104
+
105
105
  # This portion can fail in rare, FS related instances. If it does, set
106
106
  # the various times to Time.at(0).
107
107
  begin
@@ -113,7 +113,7 @@ class File::Stat
113
113
  @mtime = Time.at(0)
114
114
  @ctime = Time.at(0)
115
115
  end
116
-
116
+
117
117
  @mode = 33188 if @chardev
118
118
 
119
119
  attributes = GetFileAttributesW(@file)
@@ -138,12 +138,12 @@ class File::Stat
138
138
  FileTimeToSystemTime(buffer[4,8],st)
139
139
  y,m,w,d,h,n,s,i = st.unpack('SSSSSSSS')
140
140
  @ctime = Time.local(y,m,d,h,n,s)
141
-
141
+
142
142
  st = 0.chr * 16
143
143
  FileTimeToSystemTime(buffer[12,8],st)
144
144
  y,m,w,d,h,n,s,i = st.unpack('SSSSSSSS')
145
145
  @atime = Time.local(y,m,d,h,n,s)
146
-
146
+
147
147
  st = 0.chr * 16
148
148
  FileTimeToSystemTime(buffer[20,8],st)
149
149
  y,m,w,d,h,n,s,i = st.unpack('SSSSSSSS')
@@ -156,9 +156,9 @@ class File::Stat
156
156
  raise ArgumentError, get_last_error(error_num)
157
157
  end
158
158
  end
159
-
159
+
160
160
  @blksize = get_blksize(@file)
161
-
161
+
162
162
  # This is a reasonable guess
163
163
  case @blksize
164
164
  when nil
@@ -168,7 +168,7 @@ class File::Stat
168
168
  else
169
169
  @blocks = (@size.to_f / @blksize.to_f).ceil
170
170
  end
171
-
171
+
172
172
  @readonly = attributes & FILE_ATTRIBUTE_READONLY > 0
173
173
  @hidden = attributes & FILE_ATTRIBUTE_HIDDEN > 0
174
174
  @system = attributes & FILE_ATTRIBUTE_SYSTEM > 0
@@ -182,11 +182,11 @@ class File::Stat
182
182
  @compressed = attributes & FILE_ATTRIBUTE_COMPRESSED > 0
183
183
  @offline = attributes & FILE_ATTRIBUTE_OFFLINE > 0
184
184
  @indexed = attributes & ~FILE_ATTRIBUTE_NOT_CONTENT_INDEXED > 0
185
-
185
+
186
186
  @executable = GetBinaryTypeW(@file, '')
187
187
  @regular = @file_type == FILE_TYPE_DISK
188
188
  @pipe = @file_type == FILE_TYPE_PIPE
189
-
189
+
190
190
  # Not supported and/or meaningless
191
191
  @dev_major = nil
192
192
  @dev_minor = nil
@@ -203,46 +203,46 @@ class File::Stat
203
203
  @writable = true
204
204
  @writable_real = true
205
205
  end
206
-
206
+
207
207
  ## Comparable
208
-
208
+
209
209
  # Compares two File::Stat objects. Comparsion is based on mtime only.
210
210
  #
211
211
  def <=>(other)
212
212
  @mtime.to_i <=> other.mtime.to_i
213
213
  end
214
-
214
+
215
215
  ## Miscellaneous
216
-
216
+
217
217
  # Returns whether or not the file is a block device. For MS Windows a
218
218
  # block device is a removable drive, cdrom or ramdisk.
219
- #
219
+ #
220
220
  def blockdev?
221
221
  @blockdev
222
222
  end
223
-
223
+
224
224
  # Returns whether or not the file is a character device.
225
225
  #
226
226
  def chardev?
227
227
  @chardev
228
228
  end
229
-
229
+
230
230
  # Returns whether or not the file is executable. Generally speaking, this
231
231
  # means .bat, .cmd, .com, and .exe files.
232
232
  #
233
233
  def executable?
234
234
  @executable
235
235
  end
236
-
236
+
237
237
  alias :executable_real? :executable?
238
-
238
+
239
239
  # Returns whether or not the file is a regular file, as opposed to a pipe,
240
240
  # socket, etc.
241
241
  #
242
242
  def file?
243
243
  @regular
244
244
  end
245
-
245
+
246
246
  # Identifies the type of file. The return string is one of 'file',
247
247
  # 'directory', 'characterSpecial', 'socket' or 'unknown'.
248
248
  #
@@ -263,87 +263,87 @@ class File::Stat
263
263
  end
264
264
  end
265
265
  end
266
-
266
+
267
267
  # Meaningless on Windows.
268
268
  #
269
269
  def grpowned?
270
270
  @grpowned
271
271
  end
272
-
272
+
273
273
  # Always true on Windows
274
274
  def owned?
275
275
  @owned
276
276
  end
277
-
277
+
278
278
  # Returns whether or not the file is a pipe.
279
279
  #
280
280
  def pipe?
281
281
  @pipe
282
282
  end
283
-
283
+
284
284
  alias :socket? :pipe?
285
-
285
+
286
286
  # Meaningless on Windows
287
287
  #
288
288
  def readable?
289
289
  @readable
290
290
  end
291
-
291
+
292
292
  # Meaningless on Windows
293
293
  #
294
294
  def readable_real?
295
295
  @readable_real
296
296
  end
297
-
297
+
298
298
  # Meaningless on Windows
299
299
  #
300
300
  def setgid?
301
301
  @setgid
302
302
  end
303
-
303
+
304
304
  # Meaningless on Windows
305
305
  #
306
306
  def setuid?
307
307
  @setuid
308
308
  end
309
-
309
+
310
310
  # Returns nil if statfile is a zero-length file; otherwise, returns the
311
311
  # file size. Usable as a condition in tests.
312
312
  #
313
313
  def size?
314
314
  @size > 0 ? @size : nil
315
315
  end
316
-
316
+
317
317
  # Meaningless on Windows.
318
318
  #
319
319
  def sticky?
320
320
  @sticky
321
321
  end
322
-
322
+
323
323
  # Meaningless on Windows at the moment. This may change in the future.
324
324
  #
325
325
  def symlink?
326
326
  @symlink
327
327
  end
328
-
328
+
329
329
  # Meaningless on Windows.
330
330
  #
331
331
  def writable?
332
332
  @writable
333
333
  end
334
-
334
+
335
335
  # Meaningless on Windows.
336
336
  #
337
337
  def writable_real?
338
338
  @writable_real
339
339
  end
340
-
340
+
341
341
  # Returns whether or not the file size is zero.
342
342
  #
343
343
  def zero?
344
344
  @size == 0
345
345
  end
346
-
346
+
347
347
  ## Attribute members
348
348
 
349
349
  # Returns whether or not the file is an archive file.
@@ -357,19 +357,19 @@ class File::Stat
357
357
  def compressed?
358
358
  @compressed
359
359
  end
360
-
360
+
361
361
  # Returns whether or not the file is a directory.
362
362
  #
363
363
  def directory?
364
364
  @directory
365
365
  end
366
-
366
+
367
367
  # Returns whether or not the file in encrypted.
368
368
  #
369
369
  def encrypted?
370
370
  @encrypted
371
371
  end
372
-
372
+
373
373
  # Returns whether or not the file is hidden.
374
374
  #
375
375
  def hidden?
@@ -383,34 +383,34 @@ class File::Stat
383
383
  end
384
384
 
385
385
  alias :content_indexed? :indexed?
386
-
386
+
387
387
  # Returns whether or not the file is 'normal'. This is only true if
388
388
  # virtually all other attributes are false.
389
389
  #
390
390
  def normal?
391
391
  @normal
392
392
  end
393
-
393
+
394
394
  # Returns whether or not the file is offline.
395
395
  #
396
396
  def offline?
397
397
  @offline
398
398
  end
399
-
399
+
400
400
  # Returns whether or not the file is readonly.
401
401
  #
402
402
  def readonly?
403
403
  @readonly
404
- end
404
+ end
405
405
 
406
406
  alias :read_only? :readonly?
407
-
407
+
408
408
  # Returns whether or not the file is a reparse point.
409
409
  #
410
410
  def reparse_point?
411
411
  @reparse_point
412
412
  end
413
-
413
+
414
414
  # Returns whether or not the file is a sparse file. In most cases a sparse
415
415
  # file is an image file.
416
416
  #
@@ -437,13 +437,13 @@ class File::Stat
437
437
  def atime
438
438
  @atime
439
439
  end
440
-
440
+
441
441
  # Returns the file system's block size, or nil if it cannot be determined.
442
442
  #
443
443
  def blksize
444
444
  @blksize
445
445
  end
446
-
446
+
447
447
  # Returns the number of blocks used by the file, where a block is defined
448
448
  # as size divided by blksize, rounded up.
449
449
  #
@@ -454,14 +454,14 @@ class File::Stat
454
454
  def blocks
455
455
  @blocks
456
456
  end
457
-
457
+
458
458
  # Returns a Time object containing the time that the file status associated
459
459
  # with the file was changed.
460
460
  #
461
461
  def ctime
462
462
  @ctime
463
463
  end
464
-
464
+
465
465
  # Drive letter (A-Z) of the disk containing the file. If the path is a
466
466
  # UNC path then the drive number (probably -1) is returned instead.
467
467
  #
@@ -476,19 +476,19 @@ class File::Stat
476
476
  end
477
477
  end
478
478
  end
479
-
479
+
480
480
  # Group ID. Always 0.
481
481
  #
482
482
  def gid
483
483
  @gid
484
484
  end
485
-
485
+
486
486
  # Inode number. Meaningless on NTFS.
487
487
  #
488
488
  def ino
489
489
  @ino
490
490
  end
491
-
491
+
492
492
  # Bit mask for file-mode information.
493
493
  #
494
494
  # :no-doc:
@@ -498,7 +498,7 @@ class File::Stat
498
498
  def mode
499
499
  @mode &= ~(S_IWGRP | S_IWOTH)
500
500
  end
501
-
501
+
502
502
  # Returns a Time object containing the modification time.
503
503
  #
504
504
  def mtime
@@ -510,28 +510,28 @@ class File::Stat
510
510
  def rdev
511
511
  @rdev
512
512
  end
513
-
513
+
514
514
  # Always 1
515
515
  #
516
516
  def nlink
517
517
  @nlink
518
518
  end
519
-
519
+
520
520
  # Returns the size of the file, in bytes.
521
521
  #
522
522
  def size
523
523
  @size
524
524
  end
525
-
525
+
526
526
  # User ID. Always 0.
527
527
  #
528
528
  def uid
529
529
  @uid
530
530
  end
531
-
531
+
532
532
  # Returns a stringified version of a File::Stat object.
533
533
  #
534
- def inspect
534
+ def inspect
535
535
  members = %w[
536
536
  archive? atime blksize blockdev? blocks compressed? ctime dev
537
537
  encrypted? gid hidden? indexed? ino mode mtime rdev nlink normal?
@@ -553,7 +553,7 @@ class File::Stat
553
553
 
554
554
  str
555
555
  end
556
-
556
+
557
557
  # A custom pretty print method. This was necessary not only to handle
558
558
  # the additional attributes, but to work around an error caused by the
559
559
  # builtin method for the current File::Stat class (see pp.rb).
@@ -586,12 +586,12 @@ class File::Stat
586
586
  }
587
587
  }
588
588
  end
589
-
589
+
590
590
  # Since old_init was added strictly to avoid a warning, we remove it now.
591
591
  remove_method(:old_init)
592
-
592
+
593
593
  private
594
-
594
+
595
595
  # Returns the file system's block size.
596
596
  #
597
597
  def get_blksize(file)
@@ -601,26 +601,26 @@ class File::Stat
601
601
  bytes = [0].pack('L')
602
602
  free = [0].pack('L')
603
603
  total = [0].pack('L')
604
-
604
+
605
605
  # If there's a drive letter it must contain a trailing backslash.
606
606
  # The dup is necessary here because the function modifies the argument.
607
607
  file = file.dup
608
-
608
+
609
609
  if PathStripToRootA(wide_to_multi(file))
610
610
  file = file[/^[^\0]*/] << ':'
611
611
  file << "\\" unless file[-1].chr == "\\"
612
612
  else
613
613
  file = nil # Default to the root drive on relative paths
614
614
  end
615
-
615
+
616
616
  # Don't check for an error here. Just default to nil.
617
617
  if GetDiskFreeSpaceA(file, sectors, bytes, free, total)
618
618
  size = sectors.unpack('L').first * bytes.unpack('L').first
619
619
  end
620
-
620
+
621
621
  size
622
622
  end
623
-
623
+
624
624
  # Private method to get a HANDLE when CreateFile() won't cut it.
625
625
  #
626
626
  def get_handle(file)
@@ -647,7 +647,7 @@ class File::Stat
647
647
  ensure
648
648
  CloseHandle(hdlTokenHandle)
649
649
  end
650
-
650
+
651
651
  # First call is to get the required length
652
652
  handle_info = 0.chr * 4096
653
653
  required = 0.chr * 4
@@ -660,7 +660,13 @@ class File::Stat
660
660
  count = handle_info[0,4].unpack('L').first
661
661
 
662
662
  for i in 0...count
663
- pid, type, handle, addr, access = handle_info[4+i*16,16].unpack('LSSLL')
663
+ info = handle_info[4+i*16,16].unpack('LSSLL')
664
+
665
+ # Split out like this to silence Ruby 1.9 warnings
666
+ pid = info[0]
667
+ handle = info[2]
668
+ access = info[4]
669
+
664
670
  if access & 0xffff == 3
665
671
  begin
666
672
  process = OpenProcess(0x40,1,pid)
@@ -695,7 +701,7 @@ class File::Stat
695
701
 
696
702
  return 0
697
703
  end
698
-
704
+
699
705
  # Returns the file's type (as a numeric).
700
706
  #
701
707
  def get_file_type(file)
@@ -709,9 +715,9 @@ class File::Stat
709
715
  FILE_FLAG_BACKUP_SEMANTICS, # Need this for directories
710
716
  nil
711
717
  )
712
-
718
+
713
719
  error_num = GetLastError()
714
-
720
+
715
721
  # CreateFile() chokes on locked files
716
722
  if error_num == ERROR_SHARING_VIOLATION
717
723
  drive = file[0,4] + 0.chr * 2
@@ -726,22 +732,22 @@ class File::Stat
726
732
  if handle == INVALID_HANDLE_VALUE
727
733
  raise SystemCallError, get_last_error(error_num)
728
734
  end
729
-
735
+
730
736
  file_type = GetFileType(handle)
731
737
  error_num = GetLastError()
732
- ensure
738
+ ensure
733
739
  CloseHandle(handle)
734
740
  end
735
741
 
736
742
  if file_type == FILE_TYPE_UNKNOWN && error_num != NO_ERROR
737
743
  raise SystemCallError, get_last_error(error_num)
738
744
  end
739
-
745
+
740
746
  file_type
741
747
  end
742
748
 
743
749
  private
744
-
750
+
745
751
  # Verifies that a value is either true or false
746
752
  def check_bool(val)
747
753
  raise TypeError unless val == true || val == false
@@ -30,22 +30,22 @@ class TC_Win32_File_Stat < Test::Unit::TestCase
30
30
 
31
31
  @@txt_file = 'test_file.txt'
32
32
  @@exe_file = 'test_file.exe'
33
- @@sys_file = 'C:/pagefile.sys'
33
+ @@sys_file = 'C:/pagefile.sys'
34
34
 
35
35
  File.open(@@txt_file, "w"){ |fh| fh.print "This is a test\nHello" }
36
36
  File.open(@@exe_file, "wb"){ |fh| fh.print "This is a test" }
37
37
  end
38
-
38
+
39
39
  def setup
40
- @dir = Dir.pwd
40
+ @dir = Dir.pwd
41
41
  @stat = File::Stat.new(@@txt_file)
42
42
  @attr = GetFileAttributes(@@txt_file)
43
43
  end
44
-
44
+
45
45
  def test_version
46
- assert_equal('1.3.5', File::Stat::VERSION)
46
+ assert_equal('1.3.6', File::Stat::VERSION)
47
47
  end
48
-
48
+
49
49
  # One or more tests will fail if the archive attribute on @@text_file
50
50
  # is not set.
51
51
  def test_archive
@@ -53,93 +53,93 @@ class TC_Win32_File_Stat < Test::Unit::TestCase
53
53
  assert_nothing_raised{ @stat.archive? }
54
54
  assert(@stat.archive?, '=> May fail - ignore')
55
55
  end
56
-
56
+
57
57
  def test_atime
58
58
  assert_respond_to(@stat, :atime)
59
59
  assert_kind_of(Time, @stat.atime)
60
60
  end
61
-
61
+
62
62
  def test_blksize
63
63
  assert_respond_to(@stat, :blksize)
64
64
  assert_equal(4096, @stat.blksize)
65
65
  assert_equal(4096, File::Stat.new("C:\\").blksize)
66
66
  end
67
-
67
+
68
68
  # The block dev test error out if there's no media in it.
69
69
  def test_blockdev
70
70
  assert_respond_to(@stat, :blockdev?)
71
- assert_equal(false, @stat.blockdev?)
72
- assert_equal(false, File::Stat.new('NUL').blockdev?)
71
+ assert_false(@stat.blockdev?)
72
+ assert_false(File::Stat.new('NUL').blockdev?)
73
73
 
74
74
  begin
75
- assert_equal(true, File::Stat.new(@@block_dev).blockdev?)
76
- rescue SystemCallError
77
- omit("Skipping because drive is empty")
75
+ assert_true(File::Stat.new(@@block_dev).blockdev?)
76
+ rescue StandardError, SystemCallError
77
+ omit("Skipping because drive is empty or not found")
78
78
  end
79
79
  end
80
-
80
+
81
81
  def test_blocks
82
82
  assert_respond_to(@stat, :blocks)
83
83
  assert_equal(1, @stat.blocks)
84
84
  end
85
-
85
+
86
86
  def test_chardev
87
87
  assert_respond_to(@stat, :chardev?)
88
- assert_nothing_raised{ File::Stat.new("NUL").chardev? }
88
+ assert_nothing_raised{ File::Stat.new("NUL").chardev? }
89
89
  assert_equal(true, File::Stat.new("NUL").chardev?)
90
90
  assert_equal(false, File::Stat.new("C:\\").chardev?)
91
91
  end
92
-
92
+
93
93
  def test_comparison
94
94
  assert_respond_to(@stat, :<=>)
95
95
  assert_nothing_raised{ @stat <=> File::Stat.new(@@exe_file) }
96
96
  end
97
-
97
+
98
98
  def test_compressed
99
99
  assert_respond_to(@stat, :compressed?)
100
100
  assert_nothing_raised{ @stat.compressed? }
101
101
  assert_equal(false, @stat.compressed?)
102
102
  end
103
-
103
+
104
104
  def test_ctime
105
105
  assert_respond_to(@stat, :ctime)
106
106
  assert_kind_of(Time, @stat.ctime)
107
107
  end
108
-
108
+
109
109
  # Assumes you've installed on C: drive.
110
110
  def test_dev
111
111
  assert_respond_to(@stat, :dev)
112
112
  assert_equal('C:', @stat.dev)
113
113
  end
114
-
114
+
115
115
  def test_dev_major
116
116
  assert_respond_to(@stat, :dev_major)
117
117
  assert_nil(@stat.dev_major)
118
118
  end
119
-
119
+
120
120
  def test_dev_minor
121
121
  assert_respond_to(@stat, :dev_minor)
122
122
  assert_nil(@stat.dev_minor)
123
123
  end
124
-
124
+
125
125
  def test_directory
126
126
  assert_respond_to(@stat, :directory?)
127
127
  assert_equal(false, @stat.directory?)
128
128
  assert_equal(true, File::Stat.new("C:\\").directory?)
129
129
  end
130
-
130
+
131
131
  def test_executable
132
132
  assert_respond_to(@stat, :executable?)
133
133
  assert_equal(false, @stat.executable?)
134
134
  assert_equal(true, File::Stat.new(@@exe_file).executable?)
135
135
  end
136
-
136
+
137
137
  def test_executable_real
138
138
  assert_respond_to(@stat, :executable_real?)
139
139
  assert_equal(false, @stat.executable_real?)
140
140
  assert_equal(true, File::Stat.new(@@exe_file).executable_real?)
141
141
  end
142
-
142
+
143
143
  def test_file
144
144
  assert_respond_to(@stat, :file?)
145
145
  assert_equal(true, @stat.file?)
@@ -147,121 +147,121 @@ class TC_Win32_File_Stat < Test::Unit::TestCase
147
147
  assert_equal(true, File::Stat.new(Dir.pwd).file?)
148
148
  assert_equal(false, File::Stat.new('NUL').file?)
149
149
  end
150
-
150
+
151
151
  def test_ftype
152
152
  assert_respond_to(@stat, :ftype)
153
153
  assert_equal('file', @stat.ftype)
154
154
  assert_equal('characterSpecial', File::Stat.new('NUL').ftype)
155
155
  assert_equal('directory', File::Stat.new(Dir.pwd).ftype)
156
156
  end
157
-
157
+
158
158
  def encrypted
159
159
  assert_respond_to(@stat, :encrypted?)
160
160
  assert_nothing_raised{ @stat.encrypted? }
161
161
  end
162
-
162
+
163
163
  def test_gid
164
164
  assert_respond_to(@stat, :gid)
165
165
  assert_equal(0, @stat.gid)
166
166
  end
167
-
167
+
168
168
  def test_grpowned
169
169
  assert_respond_to(@stat, :grpowned?)
170
170
  end
171
-
171
+
172
172
  def test_hidden
173
173
  assert_respond_to(@stat, :hidden?)
174
174
  assert_nothing_raised{ @stat.hidden? }
175
175
  assert_equal(false, @stat.hidden?)
176
176
  end
177
-
177
+
178
178
  def test_indexed
179
179
  assert_respond_to(@stat, :indexed?)
180
180
  assert_respond_to(@stat, :content_indexed?) # alias
181
181
  assert_nothing_raised{ @stat.indexed? }
182
182
  assert(@stat.indexed?)
183
183
  end
184
-
184
+
185
185
  def test_ino
186
186
  assert_respond_to(@stat, :ino)
187
187
  assert_equal(0, @stat.ino)
188
188
  end
189
-
189
+
190
190
  def test_inspect
191
191
  assert_respond_to(@stat, :inspect)
192
192
  end
193
-
193
+
194
194
  def test_mode
195
195
  assert_respond_to(@stat, :mode)
196
196
  assert_equal(33188, File::Stat.new(@@txt_file).mode)
197
197
  assert_equal(33261, File::Stat.new(@@exe_file).mode)
198
198
  assert_equal(16877, File::Stat.new(@dir).mode)
199
-
199
+
200
200
  SetFileAttributes(@@txt_file, 1) # Set to readonly.
201
201
  assert_equal(33060, File::Stat.new(@@txt_file).mode)
202
202
  end
203
-
203
+
204
204
  def test_mtime
205
205
  assert_respond_to(@stat, :mtime)
206
206
  assert_kind_of(Time, @stat.mtime)
207
207
  end
208
-
208
+
209
209
  def test_nlink
210
210
  assert_respond_to(@stat, :nlink)
211
211
  assert_equal(1, @stat.nlink)
212
212
  end
213
-
213
+
214
214
  def test_normal
215
215
  assert_respond_to(@stat, :normal?)
216
216
  assert_nothing_raised{ @stat.normal? }
217
217
  assert_equal(false, @stat.normal?)
218
218
  end
219
-
219
+
220
220
  def test_offline
221
221
  assert_respond_to(@stat, :offline?)
222
222
  assert_nothing_raised{ @stat.offline? }
223
223
  assert_equal(false, @stat.offline?)
224
224
  end
225
-
225
+
226
226
  def test_pipe
227
227
  assert_respond_to(@stat, :pipe?)
228
228
  assert_equal(false, @stat.pipe?)
229
229
  end
230
-
230
+
231
231
  def test_readable
232
232
  assert_respond_to(@stat, :readable?)
233
233
  assert_equal(true, @stat.readable?)
234
234
  end
235
-
235
+
236
236
  def test_readable_real
237
237
  assert_respond_to(@stat, :readable_real?)
238
238
  assert_equal(true, @stat.readable_real?)
239
239
  end
240
-
240
+
241
241
  def test_readonly
242
242
  assert_respond_to(@stat, :readonly?)
243
243
  assert_nothing_raised{ @stat.readonly? }
244
244
  assert_equal(false, @stat.readonly?)
245
245
  end
246
-
246
+
247
247
  def test_reparse_point
248
248
  assert_respond_to(@stat, :reparse_point?)
249
249
  assert_nothing_raised{ @stat.reparse_point? }
250
250
  assert_equal(false, @stat.reparse_point?)
251
- end
252
-
251
+ end
252
+
253
253
  # Assumes you've installed on C: drive.
254
254
  def test_rdev
255
255
  msg = "ignore failure if Ruby is not installed on C: drive"
256
256
  assert_respond_to(@stat, :rdev)
257
257
  assert_equal(2, @stat.rdev, msg)
258
258
  end
259
-
259
+
260
260
  def test_setgid
261
261
  assert_respond_to(@stat, :setgid?)
262
262
  assert_equal(false, @stat.setgid?)
263
263
  end
264
-
264
+
265
265
  def test_setuid
266
266
  assert_respond_to(@stat, :setuid?)
267
267
  assert_equal(false, @stat.setuid?)
@@ -271,65 +271,65 @@ class TC_Win32_File_Stat < Test::Unit::TestCase
271
271
  assert_respond_to(@stat, :size)
272
272
  assert_equal(21, @stat.size)
273
273
  end
274
-
274
+
275
275
  def test_size_system_file
276
276
  omit_if(windows_64?, 'skipping system file test on 64-bit OS')
277
- assert_nothing_raised{ File::Stat.new(@@sys_file).size }
277
+ assert_nothing_raised{ File::Stat.new(@@sys_file).size }
278
278
  end
279
-
279
+
280
280
  def test_size_bool
281
281
  assert_respond_to(@stat, :size?)
282
282
  assert_equal(21, @stat.size?)
283
283
  end
284
-
284
+
285
285
  def test_socket
286
286
  assert_respond_to(@stat, :socket?)
287
287
  assert_equal(false, @stat.socket?)
288
288
  end
289
-
289
+
290
290
  def test_sparse
291
291
  assert_respond_to(@stat, :sparse?)
292
292
  assert_nothing_raised{ @stat.sparse? }
293
293
  assert_equal(false, @stat.sparse?)
294
294
  end
295
-
295
+
296
296
  def test_sticky
297
297
  assert_respond_to(@stat, :sticky?)
298
298
  assert_equal(false, @stat.sticky?)
299
299
  end
300
-
300
+
301
301
  def test_symlink
302
302
  assert_respond_to(@stat, :symlink?)
303
303
  assert_equal(false, @stat.symlink?)
304
304
  end
305
-
305
+
306
306
  def test_system
307
307
  assert_respond_to(@stat, :system?)
308
308
  assert_nothing_raised{ @stat.system? }
309
309
  assert_equal(false, @stat.system?)
310
310
  end
311
-
311
+
312
312
  def test_temporary
313
313
  assert_respond_to(@stat, :temporary?)
314
314
  assert_nothing_raised{ @stat.temporary? }
315
315
  assert_equal(false, @stat.temporary?)
316
- end
317
-
316
+ end
317
+
318
318
  def test_uid
319
319
  assert_respond_to(@stat, :uid)
320
320
  assert_equal(0, @stat.uid)
321
321
  end
322
-
322
+
323
323
  def test_writable
324
324
  assert_respond_to(@stat, :writable?)
325
325
  assert_equal(true, @stat.writable?)
326
326
  end
327
-
327
+
328
328
  def test_writable_real
329
329
  assert_respond_to(@stat, :writable_real?)
330
330
  assert_equal(true, @stat.writable_real?)
331
331
  end
332
-
332
+
333
333
  def test_zero
334
334
  assert_respond_to(@stat, :zero?)
335
335
  assert_equal(false, @stat.zero?)
@@ -338,7 +338,7 @@ class TC_Win32_File_Stat < Test::Unit::TestCase
338
338
  def teardown
339
339
  SetFileAttributes(@@txt_file, @attr) # Set file back to normal
340
340
  @dir = nil
341
- @stat = nil
341
+ @stat = nil
342
342
  @attr = nil
343
343
  end
344
344
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'win32-file-stat'
3
- spec.version = '1.3.5'
3
+ spec.version = '1.3.6'
4
4
  spec.authors = ['Daniel J. Berger', 'Park Heesob']
5
5
  spec.license = 'Artistic 2.0'
6
6
  spec.email = 'djberg96@gmail.com'
metadata CHANGED
@@ -1,64 +1,52 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: win32-file-stat
3
- version: !ruby/object:Gem::Version
4
- hash: 17
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.3.6
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 3
9
- - 5
10
- version: 1.3.5
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Daniel J. Berger
14
9
  - Park Heesob
15
10
  autorequire:
16
11
  bindir: bin
17
12
  cert_chain: []
18
-
19
- date: 2011-11-21 00:00:00 Z
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
13
+ date: 2012-03-24 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
22
16
  name: windows-pr
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &22530490 !ruby/object:Gem::Requirement
25
18
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 23
30
- segments:
31
- - 1
32
- - 0
33
- - 0
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
34
22
  version: 1.0.0
35
23
  type: :runtime
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: test-unit
39
24
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: *22530490
26
+ - !ruby/object:Gem::Dependency
27
+ name: test-unit
28
+ requirement: &22531570 !ruby/object:Gem::Requirement
41
29
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 3
46
- segments:
47
- - 0
48
- version: "0"
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
49
34
  type: :development
50
- version_requirements: *id002
51
- description: " The win32-file-stat library provides a custom File::Stat class\n specifically tailored for MS Windows. Examples include the ability\n to retrieve file attributes (hidden, archive, etc) as well as the\n redefinition of certain core methods that either aren't implemented\n at all, such as File.blksize, or methods that aren't implemented\n properly, such as File.size.\n"
35
+ prerelease: false
36
+ version_requirements: *22531570
37
+ description: ! " The win32-file-stat library provides a custom File::Stat class\n
38
+ \ specifically tailored for MS Windows. Examples include the ability\n to retrieve
39
+ file attributes (hidden, archive, etc) as well as the\n redefinition of certain
40
+ core methods that either aren't implemented\n at all, such as File.blksize, or
41
+ methods that aren't implemented\n properly, such as File.size.\n"
52
42
  email: djberg96@gmail.com
53
43
  executables: []
54
-
55
44
  extensions: []
56
-
57
- extra_rdoc_files:
45
+ extra_rdoc_files:
58
46
  - README
59
47
  - CHANGES
60
48
  - MANIFEST
61
- files:
49
+ files:
62
50
  - CHANGES
63
51
  - lib/win32/file/stat.rb
64
52
  - MANIFEST
@@ -67,37 +55,29 @@ files:
67
55
  - test/test_file_stat.rb
68
56
  - win32-file-stat.gemspec
69
57
  homepage: http://www.rubyforge.org/projects/win32utils
70
- licenses:
58
+ licenses:
71
59
  - Artistic 2.0
72
60
  post_install_message:
73
61
  rdoc_options: []
74
-
75
- require_paths:
62
+ require_paths:
76
63
  - lib
77
- required_ruby_version: !ruby/object:Gem::Requirement
64
+ required_ruby_version: !ruby/object:Gem::Requirement
78
65
  none: false
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- hash: 3
83
- segments:
84
- - 0
85
- version: "0"
86
- required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
71
  none: false
88
- requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- hash: 3
92
- segments:
93
- - 0
94
- version: "0"
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
95
76
  requirements: []
96
-
97
77
  rubyforge_project: Win32Utils
98
- rubygems_version: 1.8.10
78
+ rubygems_version: 1.8.11
99
79
  signing_key:
100
80
  specification_version: 3
101
81
  summary: A File::Stat class tailored to MS Windows
102
- test_files:
82
+ test_files:
103
83
  - test/test_file_stat.rb