зеркало из https://github.com/github/ruby.git
* ext/pathname/pathname.c (path_birthtime): New method,
Pathname#birthtime. Proposed by Kazuhiro NISHIYAMA. [ruby-dev:48232] [Feature #9857] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
7361eb9462
Коммит
b9faaf6a55
|
@ -1,3 +1,9 @@
|
|||
Sat Jun 28 22:44:16 2014 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ext/pathname/pathname.c (path_birthtime): New method,
|
||||
Pathname#birthtime.
|
||||
Proposed by Kazuhiro NISHIYAMA. [ruby-dev:48232] [Feature #9857]
|
||||
|
||||
Sat Jun 28 20:29:03 2014 Simon Baird <simon.baird@gmail.com>
|
||||
|
||||
* ext/bigdecimal/lib/bigdecimal/math.rb (BigMath#PI): change error
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
require 'mkmf'
|
||||
have_struct_member("struct stat", "st_birthtimespec", "sys/stat.h")
|
||||
create_makefile('pathname')
|
||||
|
|
|
@ -440,6 +440,25 @@ path_atime(VALUE self)
|
|||
return rb_funcall(rb_cFile, rb_intern("atime"), 1, get_strpath(self));
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* pathname.birthtime -> time
|
||||
*
|
||||
* Returns the birth time for the file.
|
||||
* If the platform doesn't have birthtime, returns <i>ctime</i>.
|
||||
*
|
||||
* See File.birthtime.
|
||||
*/
|
||||
#if defined(HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC)
|
||||
static VALUE
|
||||
path_birthtime(VALUE self)
|
||||
{
|
||||
return rb_funcall(rb_cFile, rb_intern("birthtime"), 1, get_strpath(self));
|
||||
}
|
||||
#else
|
||||
# define path_birthtime rb_f_notimplement
|
||||
#endif
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* pathname.ctime -> time
|
||||
|
@ -1288,6 +1307,7 @@ path_f_pathname(VALUE self, VALUE str)
|
|||
*
|
||||
* These methods are a facade for File:
|
||||
* - #atime
|
||||
* - #birthtime
|
||||
* - #ctime
|
||||
* - #mtime
|
||||
* - #chmod(mode)
|
||||
|
@ -1380,6 +1400,7 @@ Init_pathname()
|
|||
rb_define_method(rb_cPathname, "binwrite", path_binwrite, -1);
|
||||
rb_define_method(rb_cPathname, "sysopen", path_sysopen, -1);
|
||||
rb_define_method(rb_cPathname, "atime", path_atime, 0);
|
||||
rb_define_method(rb_cPathname, "birthtime", path_birthtime, 0);
|
||||
rb_define_method(rb_cPathname, "ctime", path_ctime, 0);
|
||||
rb_define_method(rb_cPathname, "mtime", path_mtime, 0);
|
||||
rb_define_method(rb_cPathname, "chmod", path_chmod, 1);
|
||||
|
|
|
@ -771,6 +771,14 @@ class TestPathname < Test::Unit::TestCase
|
|||
assert_kind_of(Time, Pathname(__FILE__).atime)
|
||||
end
|
||||
|
||||
def test_birthtime
|
||||
assert_kind_of(Time, Pathname(__FILE__).birthtime)
|
||||
rescue NotImplementedError
|
||||
assert_raise(NotImplementedError) do
|
||||
File.birthtime(__FILE__)
|
||||
end
|
||||
end
|
||||
|
||||
def test_ctime
|
||||
assert_kind_of(Time, Pathname(__FILE__).ctime)
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче