2 // abstract class. Use File or Pipe.
6 // this only supports file sizes < 2^31 for now
9 if (openFiles.notNil, {
10 openFiles.copy.do({ arg file; file.close; });
18 next { ^this.getChar }
20 ^String.fill(n, { this.next; });
26 put { arg item; this.write(item); }
27 putAll { arg aCollection;
28 if (aCollection.isKindOf(RawArray), {
29 this.write( aCollection );
31 aCollection.do({ arg item; this.write(item) });
41 /* writes any of the following items in big endian byte order:
45 the name of a Symbol as chars,
47 (i.e. Strings, Int8Arrays, Int16Arrays,
51 ^this.primitiveFailed;
54 // reads big endian data
55 // buffer should be a RawArray.
56 // fills the buffer, or as much is available.
57 // returns bytes read.
59 ^this.primitiveFailed;
63 /* writes any of the following items in little endian byte order:
67 the name of a Symbol as chars,
69 (i.e. Strings, Int8Arrays, Int16Arrays,
73 ^this.primitiveFailed;
76 // reads little endian data
77 // buffer should be a RawArray.
78 // fills the buffer, or as much is available.
79 // returns bytes read.
81 ^this.primitiveFailed;
84 getLine { arg maxSize=1024;
86 string = String.newClear(maxSize);
87 ^this.prGetLine(string);
89 prGetLine { arg argString;
90 // returns a string up to lesser of next newline
91 // or length-1 of the argument string
93 ^this.primitiveFailed;
96 // for more fine grained control these read and write a single
97 // item of the specified type and size
98 getChar { _FileGetChar; ^this.primitiveFailed; }
99 getInt8 { _FileGetInt8; ^this.primitiveFailed; }
100 getInt16 { _FileGetInt16; ^this.primitiveFailed; }
101 getInt32 { _FileGetInt32; ^this.primitiveFailed; }
102 getFloat { _FileGetFloat; ^this.primitiveFailed; }
103 getDouble { _FileGetDouble; ^this.primitiveFailed; }
104 getInt16LE { _FileGetInt16LE; ^this.primitiveFailed; }
105 getInt32LE { _FileGetInt32LE; ^this.primitiveFailed; }
106 getFloatLE { _FileGetFloatLE; ^this.primitiveFailed; }
107 getDoubleLE { _FileGetDoubleLE; ^this.primitiveFailed; }
109 putChar { arg aChar; _FilePutChar; ^this.primitiveFailed; }
110 putInt8 { arg anInteger; _FilePutInt8; ^this.primitiveFailed; }
111 putInt16 { arg anInteger; _FilePutInt16; ^this.primitiveFailed; }
112 putInt32 { arg anInteger; _FilePutInt32; ^this.primitiveFailed; }
113 putFloat { arg aFloat; _FilePutFloat; ^this.primitiveFailed; }
114 putDouble { arg aFloat; _FilePutDouble; ^this.primitiveFailed; }
115 putInt16LE { arg anInteger; _FilePutInt16LE; ^this.primitiveFailed; }
116 putInt32LE { arg anInteger; _FilePutInt32LE; ^this.primitiveFailed; }
117 putFloatLE { arg aFloat; _FilePutFloatLE; ^this.primitiveFailed; }
118 putDoubleLE { arg aFloat; _FilePutDoubleLE; ^this.primitiveFailed; }
119 putString { arg aString; _FilePutString; ^this.primitiveFailed; }
120 putString0 { arg aString;
121 this.putString(aString);
124 putPascalString { arg aString;
125 this.putInt8(aString.size);
126 this.putString(aString);
131 string = String.newClear(size);
137 openFiles = openFiles.add(this);