win32-file-stat 1.2.5 → 1.2.6

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.2.6 - 29-Sep-2007
2
+ * Minor tweak to the way I handle redefining the initialize method. The
3
+ old_init alias is now removed.
4
+ * Now handles a potential failure in getting the atime, ctime and mtime,
5
+ caused by the underlying filesystem, e.g. Samba. If it fails, these
6
+ fields are set to the epoch. Thanks go an anonymous user for the spot.
7
+ * Added a Rakefile that includes tasks for installation and testing.
8
+ * Removed the install.rb file. That has been inlined into the Rakefile.
9
+
1
10
  == 1.2.5 - 5-Apr-2007
2
11
  * Now runs -w clean.
3
12
 
data/MANIFEST CHANGED
@@ -1,7 +1,7 @@
1
1
  * CHANGES
2
2
  * README
3
3
  * MANIFEST
4
- * install.rb
4
+ * Rakefile
5
5
  * win32-file-stat.gemspec
6
6
  * lib/win32/file/stat.rb
7
7
  * test/sometestfile.exe
data/README CHANGED
@@ -2,28 +2,20 @@
2
2
  A redefinition of the File::Stat class for MS Windows.
3
3
 
4
4
  = Prerequisites
5
- Ruby 1.8.0 or later.
6
- windows-pr 0.4.0 or later.
5
+ * Ruby 1.8.0 or later.
6
+ * windows-pr 0.6.0 or later.
7
7
 
8
- = Installation, pure Ruby
9
- == Manual Installation
10
- ruby test/tc_file_stat.rb (optional)
11
- ruby install.rb
12
-
13
- == Gem Installation
14
- === Local
15
- ruby test/tc_file_stat.rb (Unix, optional)
16
- gem install win32-file-stat-<version>.gem
17
- === Remote
18
- gem install win32-file-stat
8
+ = Installation
9
+ rake install (non-gem) OR rake install_gem (gems)
19
10
 
20
11
  = Synopsis
21
- require 'win32/file/stat' # Don't do this in practice - see below
12
+ # Don't 'require' like this in practice - see 'Known Issues' below
13
+ require 'win32/file/stat'
22
14
 
23
- stat = File::Stat.new('file.txt')
24
- stat.size
25
- stat.readonly?
26
- stat.hidden?
15
+ stat = File::Stat.new('file.txt')
16
+ stat.size
17
+ stat.readonly?
18
+ stat.hidden?
27
19
 
28
20
  = Differences between Ruby's File::Stat and this version:
29
21
  * The File::Stat#blksize method returns a meaningful value.
data/Rakefile ADDED
@@ -0,0 +1,30 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rbconfig'
4
+ include Config
5
+
6
+ desc 'Install the win32-file-stat package (non-gem)'
7
+ task :install do
8
+ sitelibdir = CONFIG['sitelibdir']
9
+ installdir = sitelibdir + '/win32/file'
10
+ basedir = File.dirname(installdir)
11
+ 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)
16
+ end
17
+
18
+ desc 'Install the win32-file-stat package as a gem'
19
+ task :install_gem do
20
+ ruby 'win32-file-stat.gemspec'
21
+ file = Dir["win32-file-stat*.gem"].first
22
+ sh "gem install #{file}"
23
+ end
24
+
25
+ Rake::TestTask.new do |t|
26
+ t.libs << 'test'
27
+ t.verbose = true
28
+ t.warning = true
29
+ t.test_files = FileList['test/tc_file_stat.rb']
30
+ end
@@ -21,17 +21,15 @@ class File::Stat
21
21
  include Windows::Volume
22
22
  include Comparable
23
23
 
24
- VERSION = '1.2.5'
24
+ VERSION = '1.2.6'
25
25
 
26
26
  # Defined in Ruby's win32.h. Not meant for public consumption.
27
27
  S_IWGRP = 0020
28
28
  S_IWOTH = 0002
29
29
 
30
- # This is the only way to avoid a -w warning for initialize
31
- private
32
- alias old_init initialize
33
-
34
- public
30
+ # This is the only way to avoid a -w warning for initialize. We remove
31
+ # it later, after we've defined our initialize method.
32
+ alias old_init initialize # :nodoc:
35
33
 
36
34
  # Make this package -w clean
37
35
  undef_method(:atime, :blksize, :blockdev?, :blocks, :chardev?, :ctime)
@@ -78,9 +76,18 @@ class File::Stat
78
76
  @gid = stat_buf[12, 2].unpack('s').first # Always 0
79
77
  @rdev = stat_buf[16, 4].unpack('I').first # Same as dev
80
78
  @size = stat_buf[24, 8].unpack('Q').first # Size of file in bytes
81
- @atime = Time.at(stat_buf[32, 8].unpack('Q').first) # Access time
82
- @mtime = Time.at(stat_buf[40, 8].unpack('Q').first) # Modification time
83
- @ctime = Time.at(stat_buf[48, 8].unpack('Q').first) # Creation time
79
+
80
+ # This portion can fail in rare, FS related instances. If it does, set
81
+ # the various times to Time.at(0).
82
+ begin
83
+ @atime = Time.at(stat_buf[32, 8].unpack('Q').first) # Access time
84
+ @mtime = Time.at(stat_buf[40, 8].unpack('Q').first) # Mod time
85
+ @ctime = Time.at(stat_buf[48, 8].unpack('Q').first) # Creation time
86
+ rescue
87
+ @atime = Time.at(0)
88
+ @mtime = Time.at(0)
89
+ @ctime = Time.at(0)
90
+ end
84
91
 
85
92
  @mode = 33188 if @chardev
86
93
 
@@ -151,6 +158,9 @@ class File::Stat
151
158
 
152
159
  ## Miscellaneous
153
160
 
161
+ # Returns whether or not the file is a block device. For MS Windows a
162
+ # block device is a removable drive, cdrom or ramdisk.
163
+ #
154
164
  def blockdev?
155
165
  @blockdev
156
166
  end
@@ -511,6 +521,9 @@ class File::Stat
511
521
  }
512
522
  end
513
523
 
524
+ # Since old_init was added strictly to avoid a warning, we remove it now.
525
+ remove_method(:old_init)
526
+
514
527
  private
515
528
 
516
529
  # Returns the file system's block size.
data/test/tc_file_stat.rb CHANGED
@@ -36,14 +36,14 @@ class TC_Win32_File_Stat < Test::Unit::TestCase
36
36
  end
37
37
 
38
38
  def test_version
39
- assert_equal('1.2.5', File::Stat::VERSION)
39
+ assert_equal('1.2.6', File::Stat::VERSION)
40
40
  end
41
41
 
42
42
  # One or more tests will fail if the archive attribute on @file is not set.
43
43
  def test_archive
44
44
  assert_respond_to(@stat, :archive?)
45
45
  assert_nothing_raised{ @stat.archive? }
46
- assert(@stat.archive?)
46
+ assert(@stat.archive?, '- May fail: ignore -')
47
47
  end
48
48
 
49
49
  def test_atime
@@ -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.5"
5
+ gem.version = "1.2.6"
6
6
  gem.author = "Daniel J. Berger"
7
7
  gem.email = "djberg96@gmail.com"
8
8
  gem.homepage = "http://www.rubyforge.org/projects/win32utils"
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.2
2
+ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: win32-file-stat
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.2.5
7
- date: 2007-04-05 00:00:00 -06:00
6
+ version: 1.2.6
7
+ date: 2007-09-29 00:00:00 -06:00
8
8
  summary: A File::Stat class tailored to MS Windows
9
9
  require_paths:
10
10
  - lib
@@ -32,9 +32,9 @@ files:
32
32
  - lib/win32/file/stat.rb
33
33
  - CHANGES
34
34
  - CVS
35
- - install.rb
36
35
  - lib
37
36
  - MANIFEST
37
+ - Rakefile
38
38
  - README
39
39
  - test
40
40
  - win32-file-stat.gemspec
data/install.rb DELETED
@@ -1,12 +0,0 @@
1
- require 'rbconfig'
2
- require 'fileutils'
3
- include Config
4
-
5
- sitelibdir = CONFIG['sitelibdir']
6
- installdir = sitelibdir + '/win32/file'
7
- basedir = File.dirname(installdir)
8
- file = 'lib\win32\file\stat.rb'
9
-
10
- Dir.mkdir(basedir) unless File.exists?(basedir)
11
- Dir.mkdir(installdir) unless File.exists?(installdir)
12
- FileUtils.cp(file, installdir, :verbose => true)