# File Abstract Stream
class FStream
super IOS
- super NativeFileCapable
# The path of the file.
readable var _path: nullable String = null
fun reopen
do
if not eof then close
- _file = io_open_read(_path.to_cstring)
+ _file = new NativeFile.io_open_read(_path.to_cstring)
_end_reached = false
_buffer_pos = 0
_buffer.clear
do
_path = path
prepare_buffer(10)
- _file = io_open_read(_path.to_cstring)
+ _file = new NativeFile.io_open_read(_path.to_cstring)
assert cant_open_file: _file != null
end
# Open the file at `path' for writing.
init open(path: String)
do
- _file = io_open_write(path.to_cstring)
+ _file = new NativeFile.io_open_write(path.to_cstring)
assert cant_open_file: _file != null
_path = path
_writable = true
class Stdin
super IFStream
private init do
- _file = native_stdin
+ _file = new NativeFile.native_stdin
_path = "/dev/stdin"
prepare_buffer(1)
end
class Stdout
super OFStream
private init do
- _file = native_stdout
+ _file = new NativeFile.native_stdout
_path = "/dev/stdout"
_writable = true
end
class Stderr
super OFStream
private init do
- _file = native_stderr
+ _file = new NativeFile.native_stderr
_path = "/dev/stderr"
_writable = true
end
fun io_write(buf: NativeString, len: Int): Int is extern "file_NativeFile_NativeFile_io_write_2"
fun io_close: Int is extern "file_NativeFile_NativeFile_io_close_0"
fun file_stat: FileStat is extern "file_NativeFile_NativeFile_file_stat_0"
-end
-private interface NativeFileCapable
- fun io_open_read(path: NativeString): NativeFile is extern "file_NativeFileCapable_NativeFileCapable_io_open_read_1"
- fun io_open_write(path: NativeString): NativeFile is extern "file_NativeFileCapable_NativeFileCapable_io_open_write_1"
- fun native_stdin: NativeFile is extern "file_NativeFileCapable_NativeFileCapable_native_stdin_0"
- fun native_stdout: NativeFile is extern "file_NativeFileCapable_NativeFileCapable_native_stdout_0"
- fun native_stderr: NativeFile is extern "file_NativeFileCapable_NativeFileCapable_native_stderr_0"
+ new io_open_read(path: NativeString) is extern "file_NativeFileCapable_NativeFileCapable_io_open_read_1"
+ new io_open_write(path: NativeString) is extern "file_NativeFileCapable_NativeFileCapable_io_open_write_1"
+ new native_stdin is extern "file_NativeFileCapable_NativeFileCapable_native_stdin_0"
+ new native_stdout is extern "file_NativeFileCapable_NativeFileCapable_native_stdout_0"
+ new native_stderr is extern "file_NativeFileCapable_NativeFileCapable_native_stderr_0"
end
# Standard input.
#define file_NativeFile_NativeFile_io_write_2(p, b, l) fwrite((b), 1, (l), (FILE*)(p))
#define file_NativeFile_NativeFile_io_close_0(self) fclose((FILE*)(self))
-#define file_NativeFileCapable_NativeFileCapable_io_open_read_1(self, p0) fopen((p0), "r")
+#define file_NativeFileCapable_NativeFileCapable_io_open_read_1(p0) fopen((p0), "r")
-#define file_NativeFileCapable_NativeFileCapable_io_open_write_1(self, p0) fopen((p0), "w")
-#define file_NativeFileCapable_NativeFileCapable_native_stdin_0(self) stdin
-#define file_NativeFileCapable_NativeFileCapable_native_stdout_0(self) stdout
-#define file_NativeFileCapable_NativeFileCapable_native_stderr_0(self) stderr
+#define file_NativeFileCapable_NativeFileCapable_io_open_write_1(p0) fopen((p0), "w")
+#define file_NativeFileCapable_NativeFileCapable_native_stdin_0() stdin
+#define file_NativeFileCapable_NativeFileCapable_native_stdout_0() stdout
+#define file_NativeFileCapable_NativeFileCapable_native_stderr_0() stderr
#define file_FileStat_FileStat_mode_0(self) (((struct stat*)self)->st_mode)
#define file_FileStat_FileStat_atime_0(self) (((struct stat*)self)->st_atime)
#define file_FileStat_FileStat_ctime_0(self) (((struct stat*)self)->st_ctime)