3 classvar <openDialogs, <systemIsCaseSensitive;
6 var f = this.filenameSymbol.asString;
7 systemIsCaseSensitive = not(File.exists(f.toLower) and: {File.exists(f.toUpper)});
10 *new { arg pathName, mode;
11 ^super.new.open(pathName, mode);
13 *open { arg pathName, mode;
14 ^super.new.open(pathName, mode);
16 *use { arg pathName, mode, function;
18 file = this.new(pathName, mode);
19 ^{ function.value(file) }.protect({ file.close });
21 *delete { arg pathName;
25 *mtime { arg pathName;
29 *exists { arg pathName;
33 *existsCaseSensitive { arg pathName;
34 ^if(systemIsCaseSensitive) {
37 (pathName.dirname+/+"*").pathMatch.detect{|x|x.compare(pathName)==0}.notNil
40 *realpath { arg pathName;
44 *mkdir { arg pathName;
48 *copy { arg pathNameFrom, pathNameTo;
53 var sym = #[error, not_found, regular, directory, symlink, block, character, fifo, socket, unknown];
54 ^sym.clipAt(this.prType(pathName))
56 *prType { arg pathName;
60 *fileSize { arg pathName;
67 this.prGetcwd(string = String.new(256));
70 open { arg pathName, mode;
71 /* open the file. mode is a string passed
72 to fopen, so should be one of:
73 "r","w","a","rb","wb","ab","r+","w+","a+",
76 if (this.prOpen(pathName, mode), {
80 close { // close the file
81 // the GC will not call this for you
84 openFiles.remove(this);
86 length { // returns the length of the file
88 ^this.primitiveFailed;
90 pos { // current file position
92 ^this.primitiveFailed;
95 toPos = toPos.clip(0, this.length - 1);
98 seek { arg offset = 0, origin = 0;
99 // origin is an integer, one of:
100 // 0 - from beginning of file
101 // 1 - from current position
102 // 2 - from end of file
105 ^this.primitiveFailed;
110 string = String.newClear(this.length);
115 ^this.readAllString.stripRTF;
118 ^this.readAllString.stripHTML;
122 signal = Signal.newClear(this.length);
128 prOpen { arg pathName, mode;
129 /* open the file. mode is a string passed
130 to fopen, so should be one of:
131 "r","w","a","rb","wb","ab","r+","w+","a+",
135 ^this.primitiveFailed;
139 ^this.primitiveFailed;
142 *prGetcwd { arg string;
144 ^this.primitiveFailed;
152 // pipe stdin to, or stdout from, a unix shell command.
153 *new { arg commandLine, mode;
154 ^super.new.open(commandLine, mode);
156 open { arg commandLine, mode;
157 /* open the file. mode is a string passed
158 to popen, so should be one of:
161 if ((pid = this.prOpen(commandLine, mode)).notNil) {
167 var res = this.prClose(pid);
170 openFiles.remove(this);
176 // the GC will not call this for you
178 ^this.primitiveFailed;
183 prOpen { arg pathName, mode;
184 /* open the file. mode is a string passed
185 to popen, so should be one of:
189 ^this.primitiveFailed;