Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
0d94a2e3
Commit
0d94a2e3
authored
May 09, 2019
by
KOBAYASHI Shuji
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Raise `TypeError` if the argument type is unsupported in `mrb_stat0`
parent
9a4f3029
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
16 deletions
+4
-16
mrbgems/mruby-io/src/file_test.c
mrbgems/mruby-io/src/file_test.c
+2
-13
mrbgems/mruby-io/test/file_test.rb
mrbgems/mruby-io/test/file_test.rb
+2
-3
No files found.
mrbgems/mruby-io/src/file_test.c
View file @
0d94a2e3
...
...
@@ -42,14 +42,7 @@ extern struct mrb_data_type mrb_io_type;
static
int
mrb_stat0
(
mrb_state
*
mrb
,
mrb_value
obj
,
struct
stat
*
st
,
int
do_lstat
)
{
mrb_value
tmp
;
mrb_value
io_klass
,
str_klass
;
io_klass
=
mrb_obj_value
(
mrb_class_get
(
mrb
,
"IO"
));
str_klass
=
mrb_obj_value
(
mrb_class_get
(
mrb
,
"String"
));
tmp
=
mrb_funcall
(
mrb
,
obj
,
"is_a?"
,
1
,
io_klass
);
if
(
mrb_test
(
tmp
))
{
if
(
mrb_obj_is_kind_of
(
mrb
,
obj
,
mrb_class_get
(
mrb
,
"IO"
)))
{
struct
mrb_io
*
fptr
;
fptr
=
(
struct
mrb_io
*
)
mrb_get_datatype
(
mrb
,
obj
,
&
mrb_io_type
);
...
...
@@ -60,9 +53,7 @@ mrb_stat0(mrb_state *mrb, mrb_value obj, struct stat *st, int do_lstat)
mrb_raise
(
mrb
,
E_IO_ERROR
,
"closed stream"
);
return
-
1
;
}
tmp
=
mrb_funcall
(
mrb
,
obj
,
"is_a?"
,
1
,
str_klass
);
if
(
mrb_test
(
tmp
))
{
else
{
char
*
path
=
mrb_locale_from_utf8
(
mrb_string_value_cstr
(
mrb
,
&
obj
),
-
1
);
int
ret
;
if
(
do_lstat
)
{
...
...
@@ -73,8 +64,6 @@ mrb_stat0(mrb_state *mrb, mrb_value obj, struct stat *st, int do_lstat)
mrb_locale_free
(
path
);
return
ret
;
}
return
-
1
;
}
static
int
...
...
mrbgems/mruby-io/test/file_test.rb
View file @
0d94a2e3
...
...
@@ -20,9 +20,8 @@ assert("FileTest.exist?") do
assert_equal
true
,
FileTest
.
exist?
(
io
),
"io obj - exist"
io
.
close
assert_equal
true
,
io
.
closed?
assert_raise
IOError
do
FileTest
.
exist?
(
io
)
end
assert_raise
(
IOError
)
{
FileTest
.
exist?
(
io
)
}
assert_raise
(
TypeError
)
{
File
.
exist?
(
$mrbtest_io_rfname
.
to_sym
)
}
end
assert
(
"FileTest.file?"
)
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment