5 *new { arg pathName, mode;
6 ^super.new.open(pathName, mode);
8 *open { arg pathName, mode;
9 ^super.new.open(pathName, mode);
11 *use { arg pathName, mode, function;
13 file = this.new(pathName, mode);
14 ^{ function.value(file) }.protect({ file.close });
16 *delete { arg pathName;
20 *mtime { arg pathName;
24 *exists { arg pathName;
28 *realpath { arg pathName;
32 *mkdir { arg pathName;
36 *copy { arg pathNameFrom, pathNameTo;
41 var sym = #[error, not_found, regular, directory, symlink, block, character, fifo, socket, unknown];
42 ^sym.clipAt(this.prType(pathName))
44 *prType { arg pathName;
48 *fileSize { arg pathName;
55 this.prGetcwd(string = String.new(256));
58 open { arg pathName, mode;
59 /* open the file. mode is a string passed
60 to fopen, so should be one of:
61 "r","w","a","rb","wb","ab","r+","w+","a+",
64 if (this.prOpen(pathName, mode), {
68 close { // close the file
69 // the GC will not call this for you
72 openFiles.remove(this);
74 length { // returns the length of the file
76 ^this.primitiveFailed;
78 pos { // current file position
80 ^this.primitiveFailed;
83 toPos = toPos.clip(0, this.length - 1);
86 seek { arg offset = 0, origin = 0;
87 // origin is an integer, one of:
88 // 0 - from beginning of file
89 // 1 - from current position
90 // 2 - from end of file
93 ^this.primitiveFailed;
98 string = String.newClear(this.length);
103 ^this.readAllString.stripRTF;
106 ^this.readAllString.stripHTML;
110 signal = Signal.newClear(this.length);
116 prOpen { arg pathName, mode;
117 /* open the file. mode is a string passed
118 to fopen, so should be one of:
119 "r","w","a","rb","wb","ab","r+","w+","a+",
123 ^this.primitiveFailed;
127 ^this.primitiveFailed;
130 *prGetcwd { arg string;
132 ^this.primitiveFailed;
138 // pipe stdin to, or stdout from, a unix shell command.
139 *new { arg commandLine, mode;
140 ^super.new.open(commandLine, mode);
142 open { arg commandLine, mode;
143 /* open the file. mode is a string passed
144 to popen, so should be one of:
147 if (this.prOpen(commandLine, mode), {
153 var res = this.prClose;
155 openFiles.remove(this);
159 prClose { // close the file
160 // the GC will not call this for you
162 ^this.primitiveFailed;
167 prOpen { arg pathName, mode;
168 /* open the file. mode is a string passed
169 to popen, so should be one of:
173 ^this.primitiveFailed;