BlockContext's caller is now stored in sender field
[panda.git] / st / FileStream.st
blobf0aae42b2d0b9e4e9d119d54d1cbb52a76f647f0
5 FileStream classMethod!
6 primOpen: fileName mode: anInteger
7         <primitive: 'FileStream_open'>
8         self primitiveFailed!
10 FileStream classMethod!
11 open: fileName mode: aSymbol
12         | fd mode |
13         
14         aSymbol == #read
15                 ifTrue: [mode := 0]
16                 ifFalse:
17                         [aSymbol == #write
18                                 ifTrue: [mode := 1]
19                                 ifFalse: [self error: 'mode not supported']].
20         
21         fd := self primOpen: fileName mode: mode.
22         ^ self basicNew on: fd!
24 FileStream method!
25 primRead: fd count: anInteger
26         <primitive: 'FileStream_read'>
27         self primitiveFailed!
29 FileStream method!
30 primWrite: fd byte: anInteger
31         <primitive: 'FileStream_write'>
32         self primitiveFailed!
34 FileStream method!
35 primWrite: fd byteArray: aByteArray
36         <primitive: 'FileStream_write'>
37         self primitiveFailed!
39 FileStream method!
40 primClose: fd
41         <primitive: 'FileStream_close'>
42         self primitiveFailed!
44 FileStream method!
45 next
46         "Read the next byte from the receiver"
47         ^ self primRead: fdesc count: 1!
49 FileStream method!
50 next: anInteger
51         "Read the next anInteger bytes from the receiver"
52         ^ self primRead: fdesc count: anInteger!
54 FileStream method!
55 nextPut: anInteger
56         "write anInteger to the receiver."
57         ^ self primWrite: fdesc byteArray: (ByteArray with: anInteger)!
59 FileStream method!
60 nextPutAll: aByteArray
61         ^ self primWrite: fdesc byteArray: aByteArray!
64 FileStream method!
65 close
66         ^ self primClose: fdesc!
69 FileStream method!
70 on: fd
71         fdesc := fd!
72