win32-file-stat 1.2.8 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,12 @@
1
+ == 1.3.0 - 1-Aug-2008
2
+ * Fixed a couple of function calls where I had forgotten to call an
3
+ explicitly wide version.
4
+ * No longer ignores failures on empty block devices, e.g. CD-ROM drives
5
+ without any media in them. A SystemCallError is raised instead.
6
+ * Added blockdev boolean to the inspect/pp output.
7
+ * Fixed a potential issue with an internal helper function and the new 'S'
8
+ prototype from win32-api 1.2.0 or later.
9
+
1
10
  == 1.2.8 - 29-Jul-2008
2
11
  * Internally now always uses wide character functions.
3
12
  * A private alias was made private.
data/README CHANGED
@@ -33,7 +33,7 @@ rake install (non-gem) OR rake install_gem (gems)
33
33
  * The File::Stat#socket method works more accurately.
34
34
  * Allows you to get file attributes specific to MS Windows, e.g. archive,
35
35
  hidden, etc.
36
- * The pp (pretty print) output has been customized.
36
+ * The inspect and pretty print output has been customized.
37
37
 
38
38
  = Known issues
39
39
  You should not require 'win32/file/stat' directly. Instead, require the
@@ -21,7 +21,7 @@ class File::Stat
21
21
  include Windows::Volume
22
22
  include Comparable
23
23
 
24
- VERSION = '1.2.8'
24
+ VERSION = '1.3.0'
25
25
 
26
26
  private
27
27
 
@@ -414,7 +414,7 @@ class File::Stat
414
414
  # UNC path then the drive number (probably -1) is returned instead.
415
415
  #
416
416
  def dev
417
- if PathIsUNC(@file)
417
+ if PathIsUNCW(@file)
418
418
  @dev
419
419
  else
420
420
  (@dev + ?A).chr + ':'
@@ -477,9 +477,10 @@ class File::Stat
477
477
  #
478
478
  def inspect
479
479
  members = %w/
480
- archive? atime blksize blocks compressed? ctime dev encrypted? gid
481
- hidden? indexed? ino mode mtime rdev nlink normal? offline? readonly?
482
- reparse_point? size sparse? system? temporary? uid
480
+ archive? atime blksize blockdev? blocks compressed? ctime dev
481
+ encrypted? gid hidden? indexed? ino mode mtime rdev nlink normal?
482
+ offline? readonly? reparse_point? size sparse? system? temporary?
483
+ uid
483
484
  /
484
485
  str = "#<#{self.class}"
485
486
  members.sort.each{ |mem|
@@ -500,9 +501,10 @@ class File::Stat
500
501
  #
501
502
  def pretty_print(q)
502
503
  members = %w/
503
- archive? atime blksize blocks compressed? ctime dev encrypted? gid
504
- hidden? indexed? ino mode mtime rdev nlink normal? offline? readonly?
505
- reparse_point? size sparse? system? temporary? uid
504
+ archive? atime blksize blockdev? blocks compressed? ctime dev
505
+ encrypted? gid hidden? indexed? ino mode mtime rdev nlink normal?
506
+ offline? readonly? reparse_point? size sparse? system? temporary?
507
+ uid
506
508
  /
507
509
 
508
510
  q.object_group(self){
@@ -542,16 +544,17 @@ class File::Stat
542
544
  total = [0].pack('L')
543
545
 
544
546
  # If there's a drive letter it must contain a trailing backslash.
545
- # The dup is necessary here because, for some odd reason, the function
546
- # appears to modify the argument passed in.
547
- if PathStripToRootW(file.dup)
547
+ # The dup is necessary here because the function modifies the argument.
548
+ file = file.dup
549
+
550
+ if PathStripToRootW(file)
548
551
  file += "\\" unless file[-1].chr == "\\"
549
552
  else
550
- file = 0 # Default to root drive
553
+ file = nil # Default to the root drive on relative paths
551
554
  end
552
555
 
553
556
  # Don't check for an error here. Just default to nil.
554
- if GetDiskFreeSpace(file, sectors, bytes, free, total)
557
+ if GetDiskFreeSpaceW(file, sectors, bytes, free, total)
555
558
  size = sectors.unpack('L').first * bytes.unpack('L').first
556
559
  end
557
560
 
@@ -564,8 +567,8 @@ class File::Stat
564
567
  begin
565
568
  handle = CreateFileW(
566
569
  file,
567
- GENERIC_READ,
568
- FILE_SHARE_READ,
570
+ 0,
571
+ 0,
569
572
  nil,
570
573
  OPEN_EXISTING,
571
574
  FILE_FLAG_BACKUP_SEMANTICS, # Need this for directories
@@ -578,9 +581,7 @@ class File::Stat
578
581
  # SystemCallError explicitly here in order to maintain compatibility
579
582
  # with the FileUtils module.
580
583
  if handle == INVALID_HANDLE_VALUE
581
- unless error_num == ERROR_NOT_READY
582
- raise SystemCallError, get_last_error(error_num)
583
- end
584
+ raise SystemCallError, get_last_error(error_num)
584
585
  end
585
586
 
586
587
  file_type = GetFileType(handle)
@@ -602,4 +603,4 @@ class File::Stat
602
603
  def check_bool(val)
603
604
  raise TypeError unless val == true || val == false
604
605
  end
605
- end
606
+ end
@@ -30,7 +30,7 @@ class TC_Win32_File_Stat < Test::Unit::TestCase
30
30
  end
31
31
 
32
32
  def test_version
33
- assert_equal('1.2.8', File::Stat::VERSION)
33
+ assert_equal('1.3.0', 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.
@@ -48,8 +48,10 @@ class TC_Win32_File_Stat < Test::Unit::TestCase
48
48
  def test_blksize
49
49
  assert_respond_to(@stat, :blksize)
50
50
  assert_equal(4096, @stat.blksize)
51
+ assert_equal(4096, File::Stat.new("C:\\").blksize)
51
52
  end
52
53
 
54
+ # The block dev test error out if there's no media in it.
53
55
  def test_blockdev
54
56
  assert_respond_to(@stat, :blockdev?)
55
57
  assert_equal(false, @stat.blockdev?)
@@ -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.2.8"
5
+ gem.version = "1.3.0"
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"
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.2.8
4
+ version: 1.3.0
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-07-29 00:00:00 -06:00
13
+ date: 2008-08-01 00:00:00 -06:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency