last_error = new IOError("cannot write to non-writable stream")
return
end
- write_native(s.items, s.length)
+ write_native(s.items, 0, s.length)
end
redef fun write(s)
redef var is_writable = false
# Write `len` bytes from `native`.
- private fun write_native(native: NativeString, len: Int)
+ private fun write_native(native: NativeString, from, len: Int)
do
if last_error != null then return
if not _is_writable then
_is_writable = false
return
end
- var err = _file.io_write(native, len)
+ var err = _file.io_write(native, from, len)
if err != len then
# Big problem
last_error = new IOError("Problem in writing : {err} {len} \n")
# Path to this file
redef fun to_s do return path
- # Name of the file name at `to_s`
+ # Short name of the file at `to_s`
#
# ~~~
# var path = "/tmp/somefile".to_path
return fread(buf, 1, len, self);
`}
- fun io_write(buf: NativeString, len: Int): Int `{
- return fwrite(buf, 1, len, self);
+ fun io_write(buf: NativeString, from, len: Int): Int `{
+ return fwrite(buf+from, 1, len, self);
`}
- fun write_byte(value: Int): Int `{
+ fun write_byte(value: Byte): Int `{
unsigned char b = (unsigned char)value;
return fwrite(&b, 1, 1, self);
`}