mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
file.c: export rb_stat_new
* file.c (stat_new_0): constify. * file.c (rb_stat_new): constify and export. based on a patch by Hanmac (Hans Mackowiak) at [ruby-core:53225]. [Feature #8050] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f09b772de6
commit
c07c33b28a
4 changed files with 33 additions and 7 deletions
|
@ -1,3 +1,10 @@
|
|||
Tue Oct 1 20:54:33 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* file.c (stat_new_0): constify.
|
||||
|
||||
* file.c (rb_stat_new): constify and export. based on a patch by
|
||||
Hanmac (Hans Mackowiak) at [ruby-core:53225]. [Feature #8050]
|
||||
|
||||
Tue Oct 1 16:03:42 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* include/ruby/ruby.h (ruby_safe_level_4_warning): needed by extension
|
||||
|
|
14
file.c
14
file.c
|
@ -365,7 +365,7 @@ static const rb_data_type_t stat_data_type = {
|
|||
};
|
||||
|
||||
static VALUE
|
||||
stat_new_0(VALUE klass, struct stat *st)
|
||||
stat_new_0(VALUE klass, const struct stat *st)
|
||||
{
|
||||
struct stat *nst = 0;
|
||||
|
||||
|
@ -376,8 +376,8 @@ stat_new_0(VALUE klass, struct stat *st)
|
|||
return TypedData_Wrap_Struct(klass, &stat_data_type, nst);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
stat_new(struct stat *st)
|
||||
VALUE
|
||||
rb_stat_new(const struct stat *st)
|
||||
{
|
||||
return stat_new_0(rb_cStat, st);
|
||||
}
|
||||
|
@ -987,7 +987,7 @@ rb_file_s_stat(VALUE klass, VALUE fname)
|
|||
if (rb_stat(fname, &st) < 0) {
|
||||
rb_sys_fail_path(fname);
|
||||
}
|
||||
return stat_new(&st);
|
||||
return rb_stat_new(&st);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1015,7 +1015,7 @@ rb_io_stat(VALUE obj)
|
|||
if (fstat(fptr->fd, &st) == -1) {
|
||||
rb_sys_fail_path(fptr->pathv);
|
||||
}
|
||||
return stat_new(&st);
|
||||
return rb_stat_new(&st);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1044,7 +1044,7 @@ rb_file_s_lstat(VALUE klass, VALUE fname)
|
|||
if (lstat(StringValueCStr(fname), &st) == -1) {
|
||||
rb_sys_fail_path(fname);
|
||||
}
|
||||
return stat_new(&st);
|
||||
return rb_stat_new(&st);
|
||||
#else
|
||||
return rb_file_s_stat(klass, fname);
|
||||
#endif
|
||||
|
@ -1079,7 +1079,7 @@ rb_file_lstat(VALUE obj)
|
|||
if (lstat(RSTRING_PTR(path), &st) == -1) {
|
||||
rb_sys_fail_path(fptr->pathv);
|
||||
}
|
||||
return stat_new(&st);
|
||||
return rb_stat_new(&st);
|
||||
#else
|
||||
return rb_io_stat(obj);
|
||||
#endif
|
||||
|
|
|
@ -197,6 +197,11 @@ void rb_io_read_check(rb_io_t*);
|
|||
int rb_io_read_pending(rb_io_t*);
|
||||
DEPRECATED(void rb_read_check(FILE*));
|
||||
|
||||
struct stat;
|
||||
VALUE rb_stat_new(const struct stat *);
|
||||
|
||||
/* gc.c */
|
||||
|
||||
RUBY_SYMBOL_EXPORT_END
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
|
14
test/-ext-/file/test_stat.rb
Normal file
14
test/-ext-/file/test_stat.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
require 'test/unit'
|
||||
require "-test-/file"
|
||||
|
||||
class Test_FileStat < Test::Unit::TestCase
|
||||
def test_stat_for_fd
|
||||
st = open(__FILE__) {|f| Bug::File::Stat.for_fd(f.fileno)}
|
||||
assert_equal(File.stat(__FILE__), st)
|
||||
end
|
||||
|
||||
def test_stat_for_path
|
||||
st = Bug::File::Stat.for_path(__FILE__)
|
||||
assert_equal(File.stat(__FILE__), st)
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue