wrap read/write in begin/rescue
git-svn-id: file:///home/svn/incoming/trunk@3086 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
08e3078d47
commit
f91281f990
|
@ -28,14 +28,26 @@ module Stream
|
|||
# This method writes the supplied buffer to the stream.
|
||||
#
|
||||
def write(buf, opts = {})
|
||||
begin
|
||||
fd.syswrite(buf)
|
||||
rescue IOError
|
||||
return 0 if (fd.abortive_close == true)
|
||||
|
||||
raise $!
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
# This method reads data of the supplied length from the stream.
|
||||
#
|
||||
def read(length = nil, opts = {})
|
||||
begin
|
||||
fd.sysread(length)
|
||||
rescue IOError
|
||||
return 0 if (fd.abortive_close == true)
|
||||
|
||||
raise $!
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue