private fun fd_to_stream(mode: CString): NativeFile `{
return fdopen((int)self, mode);
`}
+
+ # Does the file descriptor `self` refer to a terminal?
+ fun isatty: Bool `{ return isatty(self); `}
end
# Constant for read-only file streams
var p = last_byte
var c = its[p]
var st = _first_byte
- while p >= st and c != '.'.ascii do
+ while p >= st and c != u'.' do
p -= 1
c = its[p]
end
var l = s.last_byte
var its = s._items
var min = s._first_byte
- var sl = '/'.ascii
+ var sl = u'/'
while l > min and its[l] == sl do l -= 1
if l == min then return "/"
var ns = l
return (long)res;
`}
- fun write_byte(value: Byte): Int `{
+ fun write_byte(value: Int): Int `{
unsigned char b = (unsigned char)value;
return fwrite(&b, 1, 1, self);
`}