mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
IO.sysopen raises an exception when open(2) fails. closes #6.
This commit is contained in:
@@ -14,20 +14,7 @@ class File < IO
|
||||
super(fd_or_path, mode)
|
||||
else
|
||||
@path = fd_or_path
|
||||
|
||||
perm = 0666 unless perm.is_a? Fixnum
|
||||
fd = IO.sysopen(@path, mode, perm)
|
||||
if fd < 0 && Object.const_defined?(:Errno)
|
||||
begin
|
||||
Errno.handle @path
|
||||
rescue Errno::EMFILE
|
||||
GC.run(true)
|
||||
fd = IO.sysopen(@path, mode, perm)
|
||||
Errno.handle if fd < 0
|
||||
end
|
||||
elsif fd < 0
|
||||
raise NoFileError.new "no such file or directory"
|
||||
end
|
||||
super(fd, mode)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user