2 SuperCollider real time audio synthesis system
3 Copyright (c) 2002 James McCartney. All rights reserved.
4 http://www.audiosynth.com
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 Primitives for File i/o.
28 #include "PyrKernel.h"
29 #include "PyrPrimitive.h"
30 #include "PyrSymbol.h"
31 #include "PyrFilePrim.h"
32 #include "PyrFileUtils.h"
33 #include "ReadWriteMacros.h"
35 #include "SC_DirUtils.h"
43 #include "../../common/SC_SndFileHelpers.hpp"
46 #include <TextUtils.h>
47 #include <Navigation.h>
55 # define strcasecmp stricmp
60 #include "SC_Win32Utils.h"
61 #include "SC_DirUtils.h"
67 #include <boost/filesystem.hpp>
69 #if defined(__APPLE__) || defined(SC_IPHONE)
70 #ifndef _SC_StandAloneInfo_
71 # include "SC_StandAloneInfo_Darwin.h"
73 # include <CoreFoundation/CFString.h>
74 # include <CoreFoundation/CFBundle.h>
76 # include <CoreServices/CoreServices.h>
82 bool filelen(FILE *file
, size_t *length
);
84 int prFileDelete(struct VMGlobals
*g
, int numArgsPushed
)
86 PyrSlot
*a
= g
->sp
- 1, *b
= g
->sp
;
87 char filename
[PATH_MAX
];
89 int error
= slotStrVal(b
, filename
, PATH_MAX
);
93 int err
= unlink(filename
);
99 int prFileMTime(struct VMGlobals
* g
, int numArgsPushed
)
101 PyrSlot
*a
= g
->sp
- 1, *b
= g
->sp
;
102 char filename
[PATH_MAX
];
104 int error
= slotStrVal(b
, filename
, PATH_MAX
);
105 if (error
!= errNone
)
108 time_t mtime
= boost::filesystem::last_write_time(filename
);
113 int prFileExists(struct VMGlobals
* g
, int numArgsPushed
)
115 PyrSlot
*a
= g
->sp
- 1, *b
= g
->sp
;
116 char filename
[PATH_MAX
];
118 int error
= slotStrVal(b
, filename
, PATH_MAX
);
119 if (error
!= errNone
)
122 bool res
= boost::filesystem::exists(filename
);
127 int prFileRealPath(struct VMGlobals
* g
, int numArgsPushed
)
129 PyrSlot
*a
= g
->sp
- 1, *b
= g
->sp
;
130 char ipath
[PATH_MAX
];
131 char opath
[PATH_MAX
];
134 err
= slotStrVal(b
, ipath
, PATH_MAX
);
137 bool isAlias
= false;
138 if(sc_ResolveIfAlias(ipath
, opath
, isAlias
, PATH_MAX
)!=0) {
142 boost::system::error_code error_code
;
143 boost::filesystem::path p
= boost::filesystem::canonical(opath
,error_code
);
148 strcpy(opath
,p
.string().c_str());
151 CFStringRef cfstring
=
152 CFStringCreateWithCString(NULL
,
154 kCFStringEncodingUTF8
);
155 err
= !CFStringGetFileSystemRepresentation(cfstring
, opath
, PATH_MAX
);
157 if (err
) return errFailed
;
160 PyrString
* pyrString
= newPyrString(g
->gc
, opath
, 0, true);
161 SetObject(a
, pyrString
);
166 int prFileMkDir(struct VMGlobals
* g
, int numArgsPushed
)
168 PyrSlot
*a
= g
->sp
- 1, *b
= g
->sp
;
169 char filename
[PATH_MAX
];
171 int error
= slotStrVal(b
, filename
, PATH_MAX
);
172 if (error
!= errNone
)
175 boost::system::error_code error_code
;
176 boost::filesystem::create_directories(filename
, error_code
);
178 postfl("Warning: %s (\"%s\")\n", error_code
.message().c_str(), filename
);
183 int prFileCopy(struct VMGlobals
* g
, int numArgsPushed
)
185 PyrSlot
*a
= g
->sp
- 2, *b
= g
->sp
- 1, *c
= g
->sp
;
186 char filename1
[PATH_MAX
];
187 char filename2
[PATH_MAX
];
189 error
= slotStrVal(b
, filename1
, PATH_MAX
);
190 if (error
!= errNone
)
192 error
= slotStrVal(c
, filename2
, PATH_MAX
);
193 if (error
!= errNone
)
196 boost::filesystem3::copy(filename1
, filename2
);
200 int prFileType(struct VMGlobals
* g
, int numArgsPushed
)
202 PyrSlot
*a
= g
->sp
- 1, *b
= g
->sp
;
203 char filename
[PATH_MAX
];
205 int error
= slotStrVal(b
, filename
, PATH_MAX
);
206 if (error
!= errNone
)
209 boost::filesystem::file_status
s(boost::filesystem::symlink_status(filename
));
214 int prFileSize(struct VMGlobals
* g
, int numArgsPushed
)
216 PyrSlot
*a
= g
->sp
- 1, *b
= g
->sp
;
217 char filename
[PATH_MAX
];
219 int error
= slotStrVal(b
, filename
, PATH_MAX
);
220 if (error
!= errNone
)
223 uintmax_t sz
= boost::filesystem::file_size(filename
);
229 int prFileOpen(struct VMGlobals
*g
, int numArgsPushed
)
232 char filename
[PATH_MAX
];
240 if (NotObj(c
) || !isKindOf(slotRawObject(c
), class_string
)
241 || NotObj(b
) || !isKindOf(slotRawObject(b
), class_string
))
243 if (slotRawObject(b
)->size
> PATH_MAX
- 1) return errFailed
;
244 if (slotRawObject(c
)->size
> 11) return errFailed
;
245 pfile
= (PyrFile
*)slotRawObject(a
);
247 memcpy(filename
, slotRawString(b
)->s
, slotRawObject(b
)->size
);
248 filename
[slotRawString(b
)->size
] = 0;
250 memcpy(mode
, slotRawString(c
)->s
, slotRawObject(c
)->size
);
251 mode
[slotRawString(c
)->size
] = 0;
254 win32_ReplaceCharInString(filename
,PATH_MAX
,'/','\\');
255 if(strcmp(mode
,"w") == 0)
257 if(strcmp(mode
,"r") == 0)
261 file
= fopen(filename
, mode
);
263 SetPtr(&pfile
->fileptr
, file
);
267 // check if directory exisits
268 // create a temporary file (somewhere) for a handle
269 // the file is deleted automatically when closed
270 if (sc_DirectoryExists(filename
)) {
273 err
= tmpfile_s(&file
);
275 SetPtr(&pfile
->fileptr
, file
);
279 #elif defined(__MINGW32__)
282 SetPtr(&pfile
->fileptr
, file
);
287 #error compiler unsupported
297 int prFileClose(struct VMGlobals
*g
, int numArgsPushed
)
304 pfile
= (PyrFile
*)slotRawObject(a
);
305 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
306 if (file
== NULL
) return errNone
;
307 SetPtr(&pfile
->fileptr
, NULL
);
308 if (fclose(file
)) return errFailed
;
312 int prFileFlush(struct VMGlobals
*g
, int numArgsPushed
)
319 pfile
= (PyrFile
*)slotRawObject(a
);
320 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
321 if (file
!= NULL
) fflush(file
);
325 int prFilePos(struct VMGlobals
*g
, int numArgsPushed
)
334 pfile
= (PyrFile
*)slotRawObject(a
);
335 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
336 if (file
== NULL
) return errFailed
;
337 if (fgetpos(file
, &pos
)) return errFailed
;
350 int prFileLength(struct VMGlobals
*g
, int numArgsPushed
)
359 pfile
= (PyrFile
*)slotRawObject(a
);
360 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
361 if (file
== NULL
) return errFailed
;
362 // preserve file position
363 if (fgetpos(file
, &pos
)) return errFailed
;
364 if (filelen(file
, &length
)) return errFailed
;
365 if (fsetpos(file
, &pos
)) return errFailed
;
371 int prFileSeek(struct VMGlobals
*g
, int numArgsPushed
)
378 static int originTable
[3] = { SEEK_SET
, SEEK_CUR
, SEEK_END
};
383 if (NotInt(b
)) return errWrongType
;
384 if (NotInt(c
)) return errWrongType
;
385 pfile
= (PyrFile
*)slotRawObject(a
);
386 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
387 if (file
== NULL
) return errFailed
;
388 offset
= slotRawInt(b
);
389 origin
= slotRawInt(c
);
390 if (origin
< 0 || origin
> 2) return errIndexOutOfRange
;
391 origin
= originTable
[origin
]; // translate in case ANSI constants ever change..
392 if (fseek(file
, offset
, origin
)) return errFailed
;
397 int prFileWrite(struct VMGlobals
*g
, int numArgsPushed
)
399 PyrSlot
*a
, *b
, *ptr
;
407 pfile
= (PyrFile
*)slotRawObject(a
);
408 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
409 if (file
== NULL
) return errFailed
;
413 SC_IOStream
<FILE*> scio(file
);
414 scio
.writeInt32_be(slotRawInt(b
));
418 fwrite(slotRawSymbol(b
)->name
, sizeof(char), slotRawSymbol(b
)->length
, file
);
421 chr
= slotRawChar(b
);
422 fwrite(&chr
, sizeof(char), 1, file
);
431 // writes the indexable part of any non obj_slot format object
432 obj
= slotRawObject(b
);
433 if (!isKindOf(obj
, class_rawarray
)
434 || isKindOf(obj
, class_symbolarray
)) return errWrongType
;
437 int elemSize
= gFormatElemSize
[obj
->obj_format
];
438 int numElems
= obj
->size
;
439 #if BYTE_ORDER != BIG_ENDIAN
442 fwrite(ptr
, elemSize
, numElems
, file
);
446 char *ptr
= slotRawString(b
)->s
;
447 char *ptrend
= ptr
+ numElems
*2;
448 for (; ptr
< ptrend
; ptr
+=2) {
456 char *ptr
= slotRawString(b
)->s
;
457 char *ptrend
= ptr
+ numElems
*4;
458 for (; ptr
< ptrend
; ptr
+=4) {
468 char *ptr
= slotRawString(b
)->s
;
469 char *ptrend
= ptr
+ numElems
*8;
470 for (; ptr
< ptrend
; ptr
+=8) {
484 fwrite(ptr
, elemSize
, numElems
, file
);
491 SC_IOStream
<FILE*> scio(file
);
492 scio
.writeDouble_be(slotRawFloat(b
));
500 int prFileWriteLE(struct VMGlobals
*g
, int numArgsPushed
)
502 PyrSlot
*a
, *b
, *ptr
;
510 pfile
= (PyrFile
*)slotRawObject(a
);
511 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
512 if (file
== NULL
) return errFailed
;
516 SC_IOStream
<FILE*> scio(file
);
517 scio
.writeInt32_le(slotRawInt(b
));
521 fwrite(slotRawSymbol(b
)->name
, sizeof(char), slotRawSymbol(b
)->length
, file
);
525 fwrite(&chr
, sizeof(char), 1, file
);
534 // writes the indexable part of any non obj_slot format object
535 obj
= slotRawObject(b
);
536 if (!isKindOf(obj
, class_rawarray
)
537 || isKindOf(obj
, class_symbolarray
)) return errWrongType
;
540 int elemSize
= gFormatElemSize
[obj
->obj_format
];
541 int numElems
= obj
->size
;
542 #if BYTE_ORDER == BIG_ENDIAN
545 fwrite(ptr
, elemSize
, numElems
, file
);
549 char *ptr
= slotRawString(b
)->s
;
550 char *ptrend
= ptr
+ numElems
*2;
551 for (; ptr
< ptrend
; ptr
+=2) {
559 char *ptr
= slotRawString(b
)->s
;
560 char *ptrend
= ptr
+ numElems
*4;
561 for (; ptr
< ptrend
; ptr
+=4) {
571 char *ptr
= slotRawString(b
)->s
;
572 char *ptrend
= ptr
+ numElems
*8;
573 for (; ptr
< ptrend
; ptr
+=8) {
587 fwrite(ptr
, elemSize
, numElems
, file
);
594 SC_IOStream
<FILE*> scio(file
);
595 scio
.writeDouble_le(slotRawFloat(b
));
602 int prFileReadLine(struct VMGlobals
*g
, int numArgsPushed
)
604 PyrSlot
*a
, *b
; // receiver(a File), string
611 pfile
= (PyrFile
*)slotRawObject(a
);
612 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
613 if (file
== NULL
) return errFailed
;
615 char* result
= fgets(slotRawString(b
)->s
, MAXINDEXSIZE(slotRawObject(b
)) - 1, file
);
619 slotRawString(b
)->size
= strlen(slotRawString(b
)->s
);
620 if (slotRawString(b
)->s
[slotRawString(b
)->size
-1] == '\n') slotRawString(b
)->size
--;
626 int prFilePutInt32(struct VMGlobals
*g
, int numArgsPushed
)
635 pfile
= (PyrFile
*)slotRawObject(a
);
636 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
637 if (file
== NULL
) return errFailed
;
640 int err
= slotIntVal(b
, &val
);
643 SC_IOStream
<FILE*> scio(file
);
644 scio
.writeInt32_be(val
);
649 int prFilePutInt16(struct VMGlobals
*g
, int numArgsPushed
)
658 pfile
= (PyrFile
*)slotRawObject(a
);
659 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
660 if (file
== NULL
) return errFailed
;
663 int err
= slotIntVal(b
, &val
);
667 SC_IOStream
<FILE*> scio(file
);
668 scio
.writeInt16_be(val
);
674 int prFilePutInt32LE(struct VMGlobals
*g
, int numArgsPushed
)
683 pfile
= (PyrFile
*)slotRawObject(a
);
684 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
685 if (file
== NULL
) return errFailed
;
688 int err
= slotIntVal(b
, &val
);
691 SC_IOStream
<FILE*> scio(file
);
692 scio
.writeInt32_le(val
);
697 int prFilePutInt16LE(struct VMGlobals
*g
, int numArgsPushed
)
706 pfile
= (PyrFile
*)slotRawObject(a
);
707 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
708 if (file
== NULL
) return errFailed
;
711 int err
= slotIntVal(b
, &val
);
715 SC_IOStream
<FILE*> scio(file
);
716 scio
.writeInt16_le(val
);
721 int prFilePutInt8(struct VMGlobals
*g
, int numArgsPushed
)
730 pfile
= (PyrFile
*)slotRawObject(a
);
731 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
732 if (file
== NULL
) return errFailed
;
735 int err
= slotIntVal(b
, &val
);
739 SC_IOStream
<FILE*> scio(file
);
745 int prFilePutChar(struct VMGlobals
*g
, int numArgsPushed
)
755 pfile
= (PyrFile
*)slotRawObject(a
);
756 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
757 if (file
== NULL
) return errFailed
;
758 if (NotChar(b
)) return errWrongType
;
762 SC_IOStream
<FILE*> scio(file
);
768 int prFilePutFloat(struct VMGlobals
*g
, int numArgsPushed
)
777 pfile
= (PyrFile
*)slotRawObject(a
);
778 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
785 int err
= slotFloatVal(b
, &val
);
788 SC_IOStream
<FILE*> scio(file
);
789 scio
.writeFloat_be(val
);
794 int prFilePutDouble(struct VMGlobals
*g
, int numArgsPushed
)
803 pfile
= (PyrFile
*)slotRawObject(a
);
804 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
805 if (file
== NULL
) return errFailed
;
809 int err
= slotDoubleVal(b
, &val
);
812 SC_IOStream
<FILE*> scio(file
);
813 scio
.writeDouble_be(val
);
819 int prFilePutFloatLE(struct VMGlobals
*g
, int numArgsPushed
)
828 pfile
= (PyrFile
*)slotRawObject(a
);
829 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
836 int err
= slotFloatVal(b
, &val
);
839 SC_IOStream
<FILE*> scio(file
);
840 scio
.writeFloat_le(val
);
845 int prFilePutDoubleLE(struct VMGlobals
*g
, int numArgsPushed
)
854 pfile
= (PyrFile
*)slotRawObject(a
);
855 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
856 if (file
== NULL
) return errFailed
;
860 int err
= slotDoubleVal(b
, &val
);
863 SC_IOStream
<FILE*> scio(file
);
864 scio
.writeDouble_le(val
);
869 int prFilePutString(struct VMGlobals
*g
, int numArgsPushed
)
878 pfile
= (PyrFile
*)slotRawObject(a
);
879 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
880 if (file
== NULL
) return errFailed
;
881 if (NotObj(b
) || slotRawObject(b
)->classptr
!= class_string
) return errWrongType
;
882 string
= slotRawString(b
);
884 fwrite(string
->s
, 1, string
->size
, file
);
890 int prFileGetDouble(struct VMGlobals
*g
, int numArgsPushed
)
898 pfile
= (PyrFile
*)slotRawObject(a
);
899 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
900 if (file
== NULL
) return errFailed
;
902 if (feof(file
)) SetNil(a
);
904 SC_IOStream
<FILE*> scio(file
);
905 SetFloat(a
, scio
.readDouble_be());
910 int prFileGetFloat(struct VMGlobals
*g
, int numArgsPushed
)
918 pfile
= (PyrFile
*)slotRawObject(a
);
919 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
920 if (file
== NULL
) return errFailed
;
922 if (feof(file
)) SetNil(a
);
924 SC_IOStream
<FILE*> scio(file
);
925 SetFloat(a
, scio
.readFloat_be());
931 int prFileGetDoubleLE(struct VMGlobals
*g
, int numArgsPushed
)
939 pfile
= (PyrFile
*)slotRawObject(a
);
940 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
941 if (file
== NULL
) return errFailed
;
943 if (feof(file
)) SetNil(a
);
945 SC_IOStream
<FILE*> scio(file
);
946 SetFloat(a
, scio
.readDouble_le());
951 int prFileGetFloatLE(struct VMGlobals
*g
, int numArgsPushed
)
959 pfile
= (PyrFile
*)slotRawObject(a
);
960 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
961 if (file
== NULL
) return errFailed
;
963 if (feof(file
)) SetNil(a
);
965 SC_IOStream
<FILE*> scio(file
);
966 SetFloat(a
, scio
.readFloat_le());
971 int prFileGetChar(struct VMGlobals
*g
, int numArgsPushed
)
980 pfile
= (PyrFile
*)slotRawObject(a
);
981 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
982 if (file
== NULL
) return errFailed
;
984 int count
= fread(&z
, sizeof(char), 1, file
);
985 if (count
==0) SetNil(a
);
990 int prFileGetInt8(struct VMGlobals
*g
, int numArgsPushed
)
999 pfile
= (PyrFile
*)slotRawObject(a
);
1000 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
1001 if (file
== NULL
) return errFailed
;
1003 int count
= fread(&z
, sizeof(int8
), 1, file
);
1004 if (count
==0) SetNil(a
);
1009 int prFileGetInt16(struct VMGlobals
*g
, int numArgsPushed
)
1017 pfile
= (PyrFile
*)slotRawObject(a
);
1018 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
1019 if (file
== NULL
) return errFailed
;
1021 if (feof(file
)) SetNil(a
);
1023 SC_IOStream
<FILE*> scio(file
);
1024 SetInt(a
, scio
.readInt16_be());
1029 int prFileGetInt32(struct VMGlobals
*g
, int numArgsPushed
)
1037 pfile
= (PyrFile
*)slotRawObject(a
);
1038 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
1042 if (feof(file
)) SetNil(a
);
1044 SC_IOStream
<FILE*> scio(file
);
1045 SetInt(a
, scio
.readInt32_be());
1051 int prFileGetInt16LE(struct VMGlobals
*g
, int numArgsPushed
)
1059 pfile
= (PyrFile
*)slotRawObject(a
);
1060 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
1061 if (file
== NULL
) return errFailed
;
1063 if (feof(file
)) SetNil(a
);
1065 SC_IOStream
<FILE*> scio(file
);
1066 SetInt(a
, scio
.readInt16_le());
1071 int prFileGetInt32LE(struct VMGlobals
*g
, int numArgsPushed
)
1079 pfile
= (PyrFile
*)slotRawObject(a
);
1080 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
1081 if (file
== NULL
) return errFailed
;
1083 if (feof(file
)) SetNil(a
);
1085 SC_IOStream
<FILE*> scio(file
);
1086 SetInt(a
, scio
.readInt32_le());
1091 int prFileReadRaw(struct VMGlobals
*g
, int numArgsPushed
)
1096 PyrSlot
* a
= g
->sp
- 1;
1099 if (!isKindOfSlot(b
, class_rawarray
)
1100 || isKindOfSlot(b
, class_symbolarray
)) return errWrongType
;
1102 pfile
= (PyrFile
*)slotRawObject(a
);
1103 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
1104 if (file
== NULL
) return errFailed
;
1106 int elemSize
= gFormatElemSize
[slotRawObject(b
)->obj_format
];
1107 int numElems
= slotRawObject(b
)->size
;
1108 numElems
= fread(slotRawString(b
)->s
, elemSize
, numElems
, file
);
1109 slotRawObject(b
)->size
= numElems
;
1111 #if BYTE_ORDER != BIG_ENDIAN
1117 char *ptr
= slotRawString(b
)->s
;
1118 char *ptrend
= ptr
+ numElems
*2;
1119 for (; ptr
< ptrend
; ptr
+=2) {
1128 char *ptr
= slotRawString(b
)->s
;
1129 char *ptrend
= ptr
+ numElems
*4;
1130 for (; ptr
< ptrend
; ptr
+=4) {
1143 char *ptr
= slotRawString(b
)->s
;
1144 char *ptrend
= ptr
+ numElems
*8;
1145 for (; ptr
< ptrend
; ptr
+=8) {
1167 if (slotRawObject(b
)->size
==0) SetNil(a
);
1172 int prFileReadRawLE(struct VMGlobals
*g
, int numArgsPushed
)
1177 PyrSlot
* a
= g
->sp
- 1;
1180 if (!isKindOfSlot(b
, class_rawarray
)
1181 || isKindOfSlot(b
, class_symbolarray
)) return errWrongType
;
1183 pfile
= (PyrFile
*)slotRawObject(a
);
1184 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
1185 if (file
== NULL
) return errFailed
;
1187 int elemSize
= gFormatElemSize
[slotRawObject(b
)->obj_format
];
1188 int numElems
= slotRawObject(b
)->size
;
1189 numElems
= fread(slotRawString(b
)->s
, elemSize
, numElems
, file
);
1190 slotRawObject(b
)->size
= numElems
;
1192 #if BYTE_ORDER == BIG_ENDIAN
1198 char *ptr
= slotRawString(b
)->s
;
1199 char *ptrend
= ptr
+ numElems
*2;
1200 for (; ptr
< ptrend
; ptr
+=2) {
1209 char *ptr
= slotRawString(b
)->s
;
1210 char *ptrend
= ptr
+ numElems
*4;
1211 for (; ptr
< ptrend
; ptr
+=4) {
1224 char *ptr
= slotRawString(b
)->s
;
1225 char *ptrend
= ptr
+ numElems
*8;
1226 for (; ptr
< ptrend
; ptr
+=8) {
1248 if (slotRawObject(b
)->size
==0) SetNil(a
);
1253 int prFileGetcwd(struct VMGlobals
*g
, int numArgsPushed
)
1255 //PyrSlot* a = g->sp - 1; // File
1256 PyrSlot
* string
= g
->sp
;
1258 if (!isKindOfSlot(string
, class_string
)) return errWrongType
;
1260 char * cwd
= getcwd(slotRawString(string
)->s
,255);
1262 error(strerror(errno
));
1265 slotRawString(string
)->size
= strlen(slotRawString(string
)->s
);
1272 int prPipeOpen(struct VMGlobals
*g
, int numArgsPushed
)
1283 if (NotObj(c
) || !isKindOf(slotRawObject(c
), class_string
)
1284 || NotObj(b
) || !isKindOf(slotRawObject(b
), class_string
))
1285 return errWrongType
;
1286 if (slotRawObject(c
)->size
> 11) return errFailed
;
1287 pfile
= (PyrFile
*)slotRawObject(a
);
1289 char *commandLine
= (char*)malloc(slotRawObject(b
)->size
+ 1);
1290 memcpy(commandLine
, slotRawString(b
)->s
, slotRawObject(b
)->size
);
1291 commandLine
[slotRawString(b
)->size
] = 0;
1293 memcpy(mode
, slotRawString(c
)->s
, slotRawObject(c
)->size
);
1294 mode
[slotRawString(c
)->size
] = 0;
1297 file
= sc_popen(commandLine
, &pid
, mode
);
1300 SetPtr(&pfile
->fileptr
, file
);
1308 int prPipeClose(struct VMGlobals
*g
, int numArgsPushed
)
1318 pfile
= (PyrFile
*)slotRawObject(a
);
1319 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
1320 if (file
== NULL
) return errNone
;
1321 pid
= (pid_t
) slotRawInt(b
);
1323 SetPtr(&pfile
->fileptr
, NULL
);
1324 int perr
= sc_pclose(file
, pid
);
1333 #ifndef NO_LIBSNDFILE
1336 #include <sndfile-win.h>
1338 #include <sndfile.h>
1342 int sampleFormatToString(struct SF_INFO
*info
, const char **string
);
1343 int sampleFormatToString(struct SF_INFO
*info
, const char **string
)
1345 unsigned int format
= info
->format
& SF_FORMAT_SUBMASK
;
1348 case SF_FORMAT_DPCM_8
:
1349 case SF_FORMAT_PCM_S8
:
1352 case SF_FORMAT_DPCM_16
:
1353 case SF_FORMAT_PCM_16
:
1354 case SF_FORMAT_DWVW_16
:
1357 case SF_FORMAT_PCM_24
:
1358 case SF_FORMAT_DWVW_24
:
1361 case SF_FORMAT_PCM_32
:
1364 case SF_FORMAT_FLOAT
:
1367 case SF_FORMAT_DOUBLE
:
1370 case SF_FORMAT_ULAW
:
1373 case SF_FORMAT_ALAW
:
1384 int headerFormatToString(struct SF_INFO
*info
, const char **string
);
1385 int headerFormatToString(struct SF_INFO
*info
, const char **string
){
1386 switch (info
->format
& SF_FORMAT_TYPEMASK
)
1388 case SF_FORMAT_WAV
:
1391 case SF_FORMAT_AIFF
:
1397 case SF_FORMAT_IRCAM
:
1400 case SF_FORMAT_RAW
:
1403 case SF_FORMAT_W64
:
1406 case SF_FORMAT_FLAC
:
1409 // TODO allow other platforms to know vorbis once libsndfile 1.0.18 is established
1410 #if SC_DARWIN || SC_WIN32 || LIBSNDFILE_1018
1411 case SF_FORMAT_VORBIS
:
1416 case SF_FORMAT_PAF :
1420 case SF_FORMAT_SVX :
1424 case SF_FORMAT_NIST :
1428 case SF_FORMAT_VOC :
1432 case SF_FORMAT_MAT4 :
1436 case SF_FORMAT_MAT5 :
1440 case SF_FORMAT_PVF :
1448 case SF_FORMAT_HTK :
1452 case SF_FORMAT_SDS :
1463 int sndfileFormatInfoToStrings(struct SF_INFO
*info
, const char **stringHead
, const char **stringSample
);
1464 int sndfileFormatInfoToStrings(struct SF_INFO
*info
, const char **stringHead
, const char **stringSample
)
1467 error
= headerFormatToString(info
, stringHead
);
1468 error
= sampleFormatToString(info
, stringSample
);
1472 int prSFOpenRead(struct VMGlobals
*g
, int numArgsPushed
);
1473 int prSFOpenRead(struct VMGlobals
*g
, int numArgsPushed
)
1476 char filename
[PATH_MAX
];
1479 const char *headerstr
;
1480 const char *sampleformatstr
;
1485 if (!isKindOfSlot(b
, class_string
)) return errWrongType
;
1486 if (slotRawObject(b
)->size
> PATH_MAX
- 1) return errFailed
;
1488 memcpy(filename
, slotRawString(b
)->s
, slotRawObject(b
)->size
);
1489 filename
[slotRawString(b
)->size
] = 0;
1492 file
= sf_open(filename
, SFM_READ
, &info
);
1496 SetPtr(slotRawObject(a
)->slots
+ 0, file
);
1497 sndfileFormatInfoToStrings(&info
, &headerstr
, &sampleformatstr
);
1498 //headerFormatToString(&info, &headerstr);
1499 PyrString
*hpstr
= newPyrString(g
->gc
, headerstr
, 0, true);
1500 SetObject(slotRawObject(a
)->slots
+1, hpstr
);
1501 PyrString
*smpstr
= newPyrString(g
->gc
, sampleformatstr
, 0, true);
1502 SetObject(slotRawObject(a
)->slots
+2, smpstr
);
1503 SetInt(slotRawObject(a
)->slots
+ 3, info
.frames
);
1504 SetInt(slotRawObject(a
)->slots
+ 4, info
.channels
);
1505 SetInt(slotRawObject(a
)->slots
+ 5, info
.samplerate
);
1515 int prSFOpenWrite(struct VMGlobals
*g
, int numArgsPushed
);
1516 int prSFOpenWrite(struct VMGlobals
*g
, int numArgsPushed
)
1519 char filename
[PATH_MAX
];
1522 PyrSlot
*headerSlot
;
1523 PyrSlot
*formatSlot
;
1530 headerSlot
= (slotRawObject(a
)->slots
+ 1);
1531 formatSlot
= (slotRawObject(a
)->slots
+ 2);
1534 if (!isKindOfSlot(headerSlot
, class_string
)) return errWrongType
;
1535 if (!isKindOfSlot(formatSlot
, class_string
)) return errWrongType
;
1537 if (!isKindOfSlot(b
, class_string
)) return errWrongType
;
1538 if (slotRawObject(b
)->size
> PATH_MAX
- 1) return errFailed
;
1540 memcpy(filename
, slotRawString(b
)->s
, slotRawObject(b
)->size
);
1541 filename
[slotRawString(b
)->size
] = 0;
1544 char* headerFormat
= (char *)malloc(slotRawObject(headerSlot
)->size
);
1546 char headerFormat
[slotRawString(headerSlot
)->size
];
1548 memcpy(headerFormat
, slotRawString(headerSlot
)->s
, slotRawObject(headerSlot
)->size
);
1549 headerFormat
[slotRawString(headerSlot
)->size
] = 0;
1552 char* sampleFormat
= (char *)malloc(slotRawString(formatSlot
)->size
);
1554 char sampleFormat
[slotRawString(formatSlot
)->size
];
1556 memcpy(sampleFormat
, slotRawString(formatSlot
)->s
, slotRawObject(formatSlot
)->size
);
1557 sampleFormat
[slotRawString(formatSlot
)->size
] = 0;
1559 error
= sndfileFormatInfoFromStrings(&info
, headerFormat
, sampleFormat
);
1568 if(error
) return errFailed
;
1569 //slotIntVal(slotRawObject(a)->slots + 3, &info.frames);
1570 slotIntVal(slotRawObject(a
)->slots
+ 4, &info
.channels
);
1571 slotIntVal(slotRawObject(a
)->slots
+ 5, &info
.samplerate
);
1573 file
= sf_open(filename
, SFM_WRITE
, &info
);
1575 SetPtr(slotRawObject(a
)->slots
+0, file
);
1585 int prSFClose(struct VMGlobals
*g
, int numArgsPushed
);
1586 int prSFClose(struct VMGlobals
*g
, int numArgsPushed
)
1592 SNDFILE
*file
= (SNDFILE
*)slotRawPtr(&slotRawObject(a
)->slots
[0]);
1595 SetNil(slotRawObject(a
)->slots
+ 0);
1601 int prSFRead(struct VMGlobals
*g
, int numArgsPushed
);
1602 int prSFRead(struct VMGlobals
*g
, int numArgsPushed
)
1609 SNDFILE
*file
= (SNDFILE
*)slotRawPtr(&slotRawObject(a
)->slots
[0]);
1611 if (!isKindOfSlot(b
, class_rawarray
)) return errWrongType
;
1613 switch (slotRawObject(b
)->obj_format
) {
1615 slotRawObject(b
)->size
= sf_read_short(file
, (short*)slotRawInt8Array(b
)->b
, slotRawObject(b
)->size
);
1618 slotRawObject(b
)->size
= sf_read_int(file
, (int*)slotRawInt8Array(b
)->b
, slotRawObject(b
)->size
);
1621 slotRawObject(b
)->size
= sf_read_float(file
, (float*)slotRawInt8Array(b
)->b
, slotRawObject(b
)->size
);
1624 slotRawObject(b
)->size
= sf_read_double(file
, (double*)slotRawInt8Array(b
)->b
, slotRawObject(b
)->size
);
1627 error("sample format not supported.\n");
1634 int prSFWrite(struct VMGlobals
*g
, int numArgsPushed
);
1635 int prSFWrite(struct VMGlobals
*g
, int numArgsPushed
)
1642 SNDFILE
*file
= (SNDFILE
*)slotRawPtr(&slotRawObject(a
)->slots
[0]);
1644 if (!isKindOfSlot(b
, class_rawarray
)) return errWrongType
;
1646 switch (slotRawObject(b
)->obj_format
) {
1648 sf_write_short(file
, (short*)slotRawInt8Array(b
)->b
, slotRawObject(b
)->size
);
1651 sf_write_int(file
, (int*)slotRawInt8Array(b
)->b
, slotRawObject(b
)->size
);
1654 sf_write_float(file
, (float*)slotRawInt8Array(b
)->b
, slotRawObject(b
)->size
);
1657 sf_write_double(file
, (double*)slotRawInt8Array(b
)->b
, slotRawObject(b
)->size
);
1660 error("sample format not supported.\n");
1667 int prSFSeek(struct VMGlobals
*g
, int numArgsPushed
);
1668 int prSFSeek(struct VMGlobals
*g
, int numArgsPushed
)
1676 SNDFILE
*file
= (SNDFILE
*)slotRawPtr(&slotRawObject(a
)->slots
[0]);
1679 int err
= slotIntVal(b
, &offset
);
1680 if (err
) return err
;
1682 err
= slotIntVal(c
, &origin
);
1683 if (err
) return err
;
1685 sf_seek(file
, offset
, origin
);
1690 int prSFHeaderInfoString(struct VMGlobals
*g
, int numArgsPushed
);
1691 int prSFHeaderInfoString(struct VMGlobals
*g
, int numArgsPushed
)
1696 SNDFILE
*file
= (SNDFILE
*)slotRawPtr(&slotRawObject(a
)->slots
[0]);
1698 static char strbuffer
[(1 << 16)] ;
1699 sf_command (file
, SFC_GET_LOG_INFO
, strbuffer
, (1 << 16)) ;
1700 PyrString
*pstring
= newPyrString(g
->gc
, strbuffer
, 0, true);
1702 SetObject(a
, pstring
);
1708 #else // !NO_LIBSNDFILE
1710 int prSFOpenRead(struct VMGlobals
*g
, int numArgsPushed
)
1715 int prSFOpenWrite(struct VMGlobals
*g
, int numArgsPushed
)
1720 int prSFClose(struct VMGlobals
*g
, int numArgsPushed
)
1725 int prSFWrite(struct VMGlobals
*g
, int numArgsPushed
)
1730 int prSFRead(struct VMGlobals
*g
, int numArgsPushed
)
1735 int prSFSeek(struct VMGlobals
*g
, int numArgsPushed
)
1740 int prSFHeaderInfoString(struct VMGlobals
*g
, int numArgsPushed
)
1745 #endif // !NO_LIBSNDFILE
1751 int dir_Lookup(char *pathString
, int pathStringLength
, int index
,
1753 char *name
, int *nameLength
, int *creationDate
, int *modificationDate
,
1754 int *isDirectory
, int *isVisible
, int *sizeIfFile
);
1756 int prDirectory_At(struct VMGlobals
*g
, int numArgsPushed
);
1757 int prDirectory_At(struct VMGlobals
*g
, int numArgsPushed
)
1759 PyrSlot
*a
= g
->sp
- 2;
1760 PyrSlot
*b
= g
->sp
- 1;
1763 PyrSlot
*dirPathSlot
= slotRawObject(a
)->slots
+ 0;
1765 err
= slotIntVal(c
, &index
);
1771 char name
[256], fullPathName
[256];
1772 int nameLength
, creationDate
, modificationDate
, isDirectory
, isVisible
, sizeIfFile
;
1773 int dirPathLength
= slotRawObject(dirPathSlot
)->size
;
1775 err
= dir_Lookup(slotRawObject(dirPathSlot
)s
->s
, dirPathLength
, index
+1,
1776 name
, &nameLength
, &creationDate
, &modificationDate
, &isDirectory
, &isVisible
, &sizeIfFile
);
1782 error("Invalid path\n");
1787 if (dirPathLength
+ nameLength
+ 1 > 255) {
1788 error("Full path name too long.\n");
1793 PyrSlot
*entryName
= slotRawObject(b
)->slots
+ 0;
1794 PyrSlot
*entryPath
= slotRawObject(b
)->slots
+ 1;
1795 PyrSlot
*entryIsDir
= slotRawObject(b
)->slots
+ 2;
1796 PyrSlot
*entryIsVisible
= slotRawObject(b
)->slots
+ 3;
1798 PyrString
*nameString
= newPyrString(g
->gc
, name
, 0, true);
1799 SetObject(entryName
, nameString
);
1800 g
->gc
->GCWrite(slotRawObject(b
), (PyrObject
*)nameString
);
1802 memcpy(fullPathName
, slotRawObject(dirPathSlot
)s
->s
, dirPathLength
);
1803 fullPathName
[dirPathLength
] = DELIMITOR
;
1804 strcpy(fullPathName
+ dirPathLength
+ 1, name
);
1806 PyrString
*pathString
= newPyrString(g
->gc
, fullPathName
, 0, true);
1807 SetObject(entryPath
, pathString
);
1808 g
->gc
->GCWrite(slotRawObject(b
), (PyrObject
*)pathString
);
1810 if (isDirectory
) { SetTrue(entryIsDir
); } else { SetFalse(entryIsDir
); }
1811 if (isVisible
) { SetTrue(entryIsVisible
); } else { SetFalse(entryIsVisible
); }
1818 Boolean
GetFullPathname(const FSSpec
* aSpec
, Str255 pathname
);
1819 void pstrncpy(unsigned char *s1
, unsigned char *s2
, int n
);
1821 int prFile_GetFile(struct VMGlobals
*g
, int numArgsPushed
);
1822 int prFile_GetFile(struct VMGlobals
*g
, int numArgsPushed
)
1825 PyrSlot
*a
= g
->sp
- 1;
1828 NavDialogOptions options
;
1830 int err
= NavGetDefaultDialogOptions(&options
);
1831 if (err
) return errFailed
;
1833 options
.dialogOptionFlags
|= kNavNoTypePopup
;
1834 options
.dialogOptionFlags
|= kNavDontAutoTranslate
;
1835 options
.dialogOptionFlags
|= kNavDontAddTranslateItems
;
1836 options
.dialogOptionFlags
|= kNavSelectDefaultLocation
;
1837 options
.dialogOptionFlags
&= ~kNavAllowPreviews
;
1838 options
.dialogOptionFlags
&= ~kNavAllowMultipleFiles
;
1840 if (isKindOfSlot(b
, class_string
)) {
1841 pstringFromPyrString((PyrString
*)slotRawObject(b
), options
.message
, 256);
1844 NavReplyRecord reply
;
1845 err
= NavGetFile(0, &reply
, &options
, 0, 0, 0, 0, 0);
1847 if (err
== noErr
&& reply
.validRecord
) {
1849 DescType actualType
;
1853 err
= AEGetNthPtr(&reply
.selection
, 1, typeFSS
, &keyword
, &actualType
,
1854 &fsspec
, sizeof(FSSpec
), &actualSize
);
1858 GetFullPathname(&fsspec
, pathname
);
1860 PyrString
*string
= newPyrString(g
->gc
, (char*)pathname
, 0, true);
1861 SetObject(a
, string
);
1865 err
= NavDisposeReply(&reply
);
1874 int prFile_PutFile(struct VMGlobals
*g
, int numArgsPushed
);
1875 int prFile_PutFile(struct VMGlobals
*g
, int numArgsPushed
)
1878 PyrSlot
*a
= g
->sp
- 2;
1879 PyrSlot
*b
= g
->sp
- 1;
1882 NavDialogOptions options
;
1884 int err
= NavGetDefaultDialogOptions(&options
);
1885 if (err
) return errFailed
;
1887 options
.dialogOptionFlags
|= kNavNoTypePopup
;
1888 options
.dialogOptionFlags
|= kNavDontAutoTranslate
;
1889 options
.dialogOptionFlags
|= kNavDontAddTranslateItems
;
1890 options
.dialogOptionFlags
|= kNavSelectDefaultLocation
;
1891 options
.dialogOptionFlags
&= ~kNavAllowPreviews
;
1892 options
.dialogOptionFlags
&= ~kNavAllowMultipleFiles
;
1894 if (isKindOfSlot(b
, class_string
)) {
1895 pstringFromPyrString((PyrString
*)slotRawObject(b
), options
.message
, 256);
1898 if (isKindOfSlot(c
, class_string
)) {
1899 pstringFromPyrString((PyrString
*)slotRawObject(c
), options
.savedFileName
, 256);
1901 //pstrncpy(options.savedFileName, "\pUntitled", 255);
1904 NavReplyRecord reply
;
1905 err
= NavPutFile(0, &reply
, &options
, 0, 'TEXT', 'SCjm', 0);
1907 if (err
== noErr
&& reply
.validRecord
) {
1909 DescType actualType
;
1913 err
= AEGetNthPtr(&reply
.selection
, 1, typeFSS
, &keyword
, &actualType
,
1914 &fsspec
, sizeof(FSSpec
), &actualSize
);
1918 GetFullPathname(&fsspec
, pathname
);
1920 PyrString
*string
= newPyrString(g
->gc
, (char*)pathname
, 0, true);
1921 SetObject(a
, string
);
1923 err
= NavCompleteSave(&reply
, kNavTranslateInPlace
);
1927 err
= NavDisposeReply(&reply
);
1938 void initFilePrimitives()
1942 base
= nextPrimitiveIndex();
1945 definePrimitive(base
, index
++, "_SFOpenRead", prSFOpenRead
, 2, 0);
1946 definePrimitive(base
, index
++, "_SFOpenWrite", prSFOpenWrite
, 2, 0);
1947 definePrimitive(base
, index
++, "_SFClose", prSFClose
, 1, 0);
1948 definePrimitive(base
, index
++, "_SFWrite", prSFWrite
, 2, 0);
1949 definePrimitive(base
, index
++, "_SFRead", prSFRead
, 2, 0);
1950 definePrimitive(base
, index
++, "_SFSeek", prSFSeek
, 3, 0);
1951 definePrimitive(base
, index
++, "_SFHeaderInfoString", prSFHeaderInfoString
, 1, 0);
1953 definePrimitive(base
, index
++, "_PipeOpen", prPipeOpen
, 3, 0);
1954 definePrimitive(base
, index
++, "_PipeClose", prPipeClose
, 2, 0);
1956 definePrimitive(base
, index
++, "_FileDelete", prFileDelete
, 2, 0);
1957 definePrimitive(base
, index
++, "_FileMTime", prFileMTime
, 2, 0);
1958 definePrimitive(base
, index
++, "_FileExists", prFileExists
, 2, 0);
1959 definePrimitive(base
, index
++, "_FileRealPath", prFileRealPath
, 2, 0);
1960 definePrimitive(base
, index
++, "_FileMkDir", prFileMkDir
, 2, 0);
1961 definePrimitive(base
, index
++, "_FileCopy", prFileCopy
, 3, 0);
1962 definePrimitive(base
, index
++, "_FileType", prFileType
, 2, 0);
1963 definePrimitive(base
, index
++, "_FileSize", prFileSize
, 2, 0);
1965 definePrimitive(base
, index
++, "_FileOpen", prFileOpen
, 3, 0);
1966 definePrimitive(base
, index
++, "_FileClose", prFileClose
, 1, 0);
1967 definePrimitive(base
, index
++, "_FileFlush", prFileFlush
, 1, 0);
1968 definePrimitive(base
, index
++, "_FileSeek", prFileSeek
, 3, 0);
1969 definePrimitive(base
, index
++, "_FilePos", prFilePos
, 1, 0);
1970 definePrimitive(base
, index
++, "_FileLength", prFileLength
, 1, 0);
1971 definePrimitive(base
, index
++, "_FileWrite", prFileWrite
, 2, 0);
1972 definePrimitive(base
, index
++, "_FileWriteLE", prFileWriteLE
, 2, 0);
1973 definePrimitive(base
, index
++, "_FileReadLine", prFileReadLine
, 2, 0);
1974 definePrimitive(base
, index
++, "_File_getcwd", prFileGetcwd
, 2, 0);
1976 definePrimitive(base
, index
++, "_FilePutChar", prFilePutChar
, 2, 0);
1977 definePrimitive(base
, index
++, "_FilePutInt8", prFilePutInt8
, 2, 0);
1978 definePrimitive(base
, index
++, "_FilePutInt16", prFilePutInt16
, 2, 0);
1979 definePrimitive(base
, index
++, "_FilePutInt32", prFilePutInt32
, 2, 0);
1980 definePrimitive(base
, index
++, "_FilePutFloat", prFilePutFloat
, 2, 0);
1981 definePrimitive(base
, index
++, "_FilePutDouble", prFilePutDouble
, 2, 0);
1982 definePrimitive(base
, index
++, "_FilePutInt16LE", prFilePutInt16LE
, 2, 0);
1983 definePrimitive(base
, index
++, "_FilePutInt32LE", prFilePutInt32LE
, 2, 0);
1984 definePrimitive(base
, index
++, "_FilePutFloatLE", prFilePutFloatLE
, 2, 0);
1985 definePrimitive(base
, index
++, "_FilePutDoubleLE", prFilePutDoubleLE
, 2, 0);
1987 definePrimitive(base
, index
++, "_FileGetChar", prFileGetChar
, 1, 0);
1988 definePrimitive(base
, index
++, "_FileGetInt8", prFileGetInt8
, 1, 0);
1989 definePrimitive(base
, index
++, "_FileGetInt16", prFileGetInt16
, 1, 0);
1990 definePrimitive(base
, index
++, "_FileGetInt32", prFileGetInt32
, 1, 0);
1991 definePrimitive(base
, index
++, "_FileGetFloat", prFileGetFloat
, 1, 0);
1992 definePrimitive(base
, index
++, "_FileGetDouble", prFileGetDouble
, 1, 0);
1993 definePrimitive(base
, index
++, "_FileGetInt16LE", prFileGetInt16LE
, 1, 0);
1994 definePrimitive(base
, index
++, "_FileGetInt32LE", prFileGetInt32LE
, 1, 0);
1995 definePrimitive(base
, index
++, "_FileGetFloatLE", prFileGetFloatLE
, 1, 0);
1996 definePrimitive(base
, index
++, "_FileGetDoubleLE", prFileGetDoubleLE
, 1, 0);
1998 definePrimitive(base
, index
++, "_FilePutString", prFilePutString
, 2, 0);
2000 definePrimitive(base
, index
++, "_FileReadRaw", prFileReadRaw
, 2, 0);
2001 definePrimitive(base
, index
++, "_FileReadRawLE", prFileReadRawLE
, 2, 0);
2004 definePrimitive(base
, index
++, "_Directory_At", prDirectory_At
, 3, 0);
2005 definePrimitive(base
, index
++, "_File_GetFile", prFile_GetFile
, 2, 0);
2006 definePrimitive(base
, index
++, "_File_PutFile", prFile_PutFile
, 3, 0);