Skip to content

Commit

Permalink
Only darwin supports birthtime
Browse files Browse the repository at this point in the history
After some research only darwin seems to support birthtime via
st_birhttimespec in the stat struct.

See https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man2/stat.2.html
and https://github.com/ruby/ruby/blob/fc7711ff17cde31aec0e2c1d29faca264b49da6b/file.c#L829 for reference.
  • Loading branch information
tak1n committed May 28, 2015
1 parent 3ca2005 commit 1912f8f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
8 changes: 4 additions & 4 deletions spec/ruby/core/file/birthtime_spec.rb
Expand Up @@ -9,7 +9,7 @@
@file = nil
end

platform_is :darwin, :freebsd, :netbsd do
platform_is :darwin do
it "returns the birth time for the named file as a Time object" do
File.birthtime(@file)
File.birthtime(@file).should be_kind_of(Time)
Expand All @@ -24,7 +24,7 @@
end
end

platform_is :windows, :linux do
platform_is :windows, :linux, :openbsd, :freebsd, :netbsd do
it "raises an NotImplementedError" do
lambda { File.birthtime(@file) }.should raise_error(NotImplementedError)
end
Expand All @@ -41,14 +41,14 @@
@file = nil
end

platform_is :darwin, :freebsd, :netbsd, :openbsd do
platform_is :darwin do
it "returns the birth time for self" do
@file.birthtime
@file.birthtime.should be_kind_of(Time)
end
end

platform_is :windows, :linux do
platform_is :windows, :linux, :openbsd, :freebsd, :netbsd do
it "raises an NotImplementedError" do
lambda { @file.birthtime }.should raise_error(NotImplementedError)
end
Expand Down
7 changes: 7 additions & 0 deletions spec/ruby/core/nil/frozen_spec.rb
@@ -0,0 +1,7 @@
require File.expand_path('../../../spec_helper', __FILE__)

describe "NilClass#frozen?" do
it "returns true" do
nil.frozen?.should == true
end
end
2 changes: 1 addition & 1 deletion vm/builtin/stat.cpp
Expand Up @@ -79,7 +79,7 @@ namespace rubinius {

Object* Stat::stat_birthtime(STATE) {
#ifdef HAVE_ST_BIRTHTIME
return Time::at(state, st_.st_birthtime);
return Time::at(state, st_.st_birthtimespec);
#else
return Primitives::failure();
#endif
Expand Down

0 comments on commit 1912f8f

Please sign in to comment.