From b48ef95e4433228543d3702b947f523af47dceb5 Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Mon, 11 Nov 2019 14:23:10 +0000 Subject: [PATCH] some stream works --- moo/kernel/Stream.moo | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/moo/kernel/Stream.moo b/moo/kernel/Stream.moo index 819860b..50f7e7f 100644 --- a/moo/kernel/Stream.moo +++ b/moo/kernel/Stream.moo @@ -1,3 +1,41 @@ +interface StreamInterface +{ + method close {} + method next {} // if readable + method nextPut: item {} // if writable + method atEnd {} + method contents {} + method isReadable {} + method isWritable {} +} + +class FileStream(Object) [StreamInterface] +{ + | accessor | + + method(#class) on: path for: flags + { + | stream | + stream := self basicNew. + stream accessor: (FileAccessor on: path for: flags). + ^stream + } + + method close + { + ifnot (self.accessor isNil) + { + self.accessor close. + self.accessor := nil. + }. + } + + method next + { + + } +} + class Stream(Object) { method(#class) new @@ -338,3 +376,4 @@ class TextStream(ByteStream) if (self.seq at: 0) bitAnd: } }*/ +