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"
41 #include <TextUtils.h>
42 #include <Navigation.h>
50 # define strcasecmp stricmp
55 #include "SC_Win32Utils.h"
56 #include "SC_DirUtils.h"
64 bool filelen(FILE *file
, size_t *length
);
66 int prFileDelete(struct VMGlobals
*g
, int numArgsPushed
)
69 char filename
[PATH_MAX
];
73 if (NotObj(b
) || !isKindOf(slotRawObject(b
), class_string
))
75 if (slotRawObject(b
)->size
> PATH_MAX
- 1) return errFailed
;
77 memcpy(filename
, slotRawString(b
)->s
, slotRawObject(b
)->size
);
78 filename
[slotRawString(b
)->size
] = 0;
80 int err
= unlink(filename
);
87 int prFileOpen(struct VMGlobals
*g
, int numArgsPushed
)
90 char filename
[PATH_MAX
];
98 if (NotObj(c
) || !isKindOf(slotRawObject(c
), class_string
)
99 || NotObj(b
) || !isKindOf(slotRawObject(b
), class_string
))
101 if (slotRawObject(b
)->size
> PATH_MAX
- 1) return errFailed
;
102 if (slotRawObject(c
)->size
> 11) return errFailed
;
103 pfile
= (PyrFile
*)slotRawObject(a
);
105 memcpy(filename
, slotRawString(b
)->s
, slotRawObject(b
)->size
);
106 filename
[slotRawString(b
)->size
] = 0;
108 memcpy(mode
, slotRawString(c
)->s
, slotRawObject(c
)->size
);
109 mode
[slotRawString(c
)->size
] = 0;
112 win32_ReplaceCharInString(filename
,PATH_MAX
,'/','\\');
113 if(strcmp(mode
,"w") == 0)
115 if(strcmp(mode
,"r") == 0)
119 file
= fopen(filename
, mode
);
121 SetPtr(&pfile
->fileptr
, file
);
125 // check if directory exisits
126 // create a temporary file (somewhere) for a handle
127 // the file is deleted automatically when closed
128 if (sc_DirectoryExists(filename
)) {
131 err
= tmpfile_s(&file
);
133 SetPtr(&pfile
->fileptr
, file
);
137 #elif defined(__MINGW32__)
140 SetPtr(&pfile
->fileptr
, file
);
145 #error compiler unsupported
155 int prFileClose(struct VMGlobals
*g
, int numArgsPushed
)
162 pfile
= (PyrFile
*)slotRawObject(a
);
163 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
164 if (file
== NULL
) return errNone
;
165 SetPtr(&pfile
->fileptr
, NULL
);
166 if (fclose(file
)) return errFailed
;
170 int prFileFlush(struct VMGlobals
*g
, int numArgsPushed
)
177 pfile
= (PyrFile
*)slotRawObject(a
);
178 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
179 if (file
!= NULL
) fflush(file
);
183 int prFilePos(struct VMGlobals
*g
, int numArgsPushed
)
192 pfile
= (PyrFile
*)slotRawObject(a
);
193 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
194 if (file
== NULL
) return errFailed
;
195 if (fgetpos(file
, &pos
)) return errFailed
;
208 int prFileLength(struct VMGlobals
*g
, int numArgsPushed
)
217 pfile
= (PyrFile
*)slotRawObject(a
);
218 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
219 if (file
== NULL
) return errFailed
;
220 // preserve file position
221 if (fgetpos(file
, &pos
)) return errFailed
;
222 if (filelen(file
, &length
)) return errFailed
;
223 if (fsetpos(file
, &pos
)) return errFailed
;
229 int prFileSeek(struct VMGlobals
*g
, int numArgsPushed
)
236 static int originTable
[3] = { SEEK_SET
, SEEK_CUR
, SEEK_END
};
241 if (NotInt(b
)) return errWrongType
;
242 if (NotInt(c
)) return errWrongType
;
243 pfile
= (PyrFile
*)slotRawObject(a
);
244 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
245 if (file
== NULL
) return errFailed
;
246 offset
= slotRawInt(b
);
247 origin
= slotRawInt(c
);
248 if (origin
< 0 || origin
> 2) return errIndexOutOfRange
;
249 origin
= originTable
[origin
]; // translate in case ANSI constants ever change..
250 if (fseek(file
, offset
, origin
)) return errFailed
;
255 int prFileWrite(struct VMGlobals
*g
, int numArgsPushed
)
257 PyrSlot
*a
, *b
, *ptr
;
265 pfile
= (PyrFile
*)slotRawObject(a
);
266 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
267 if (file
== NULL
) return errFailed
;
271 SC_IOStream
<FILE*> scio(file
);
272 scio
.writeInt32_be(slotRawInt(b
));
276 fwrite(slotRawSymbol(b
)->name
, sizeof(char), slotRawSymbol(b
)->length
, file
);
279 chr
= slotRawChar(b
);
280 fwrite(&chr
, sizeof(char), 1, file
);
289 // writes the indexable part of any non obj_slot format object
290 obj
= slotRawObject(b
);
291 if (!isKindOf(obj
, class_rawarray
)
292 || isKindOf(obj
, class_symbolarray
)) return errWrongType
;
295 int elemSize
= gFormatElemSize
[obj
->obj_format
];
296 int numElems
= obj
->size
;
297 #if BYTE_ORDER != BIG_ENDIAN
300 fwrite(ptr
, elemSize
, numElems
, file
);
304 char *ptr
= slotRawString(b
)->s
;
305 char *ptrend
= ptr
+ numElems
*2;
306 for (; ptr
< ptrend
; ptr
+=2) {
314 char *ptr
= slotRawString(b
)->s
;
315 char *ptrend
= ptr
+ numElems
*4;
316 for (; ptr
< ptrend
; ptr
+=4) {
326 char *ptr
= slotRawString(b
)->s
;
327 char *ptrend
= ptr
+ numElems
*8;
328 for (; ptr
< ptrend
; ptr
+=8) {
342 fwrite(ptr
, elemSize
, numElems
, file
);
349 SC_IOStream
<FILE*> scio(file
);
350 scio
.writeDouble_be(slotRawFloat(b
));
358 int prFileWriteLE(struct VMGlobals
*g
, int numArgsPushed
)
360 PyrSlot
*a
, *b
, *ptr
;
368 pfile
= (PyrFile
*)slotRawObject(a
);
369 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
370 if (file
== NULL
) return errFailed
;
374 SC_IOStream
<FILE*> scio(file
);
375 scio
.writeInt32_le(slotRawInt(b
));
379 fwrite(slotRawSymbol(b
)->name
, sizeof(char), slotRawSymbol(b
)->length
, file
);
383 fwrite(&chr
, sizeof(char), 1, file
);
392 // writes the indexable part of any non obj_slot format object
393 obj
= slotRawObject(b
);
394 if (!isKindOf(obj
, class_rawarray
)
395 || isKindOf(obj
, class_symbolarray
)) return errWrongType
;
398 int elemSize
= gFormatElemSize
[obj
->obj_format
];
399 int numElems
= obj
->size
;
400 #if BYTE_ORDER == BIG_ENDIAN
403 fwrite(ptr
, elemSize
, numElems
, file
);
407 char *ptr
= slotRawString(b
)->s
;
408 char *ptrend
= ptr
+ numElems
*2;
409 for (; ptr
< ptrend
; ptr
+=2) {
417 char *ptr
= slotRawString(b
)->s
;
418 char *ptrend
= ptr
+ numElems
*4;
419 for (; ptr
< ptrend
; ptr
+=4) {
429 char *ptr
= slotRawString(b
)->s
;
430 char *ptrend
= ptr
+ numElems
*8;
431 for (; ptr
< ptrend
; ptr
+=8) {
445 fwrite(ptr
, elemSize
, numElems
, file
);
452 SC_IOStream
<FILE*> scio(file
);
453 scio
.writeDouble_le(slotRawFloat(b
));
460 int prFileReadLine(struct VMGlobals
*g
, int numArgsPushed
)
462 PyrSlot
*a
, *b
; // receiver(a File), string
469 pfile
= (PyrFile
*)slotRawObject(a
);
470 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
471 if (file
== NULL
) return errFailed
;
473 char* result
= fgets(slotRawString(b
)->s
, MAXINDEXSIZE(slotRawObject(b
)) - 1, file
);
477 slotRawString(b
)->size
= strlen(slotRawString(b
)->s
);
478 if (slotRawString(b
)->s
[slotRawString(b
)->size
-1] == '\n') slotRawString(b
)->size
--;
484 int prFilePutInt32(struct VMGlobals
*g
, int numArgsPushed
)
493 pfile
= (PyrFile
*)slotRawObject(a
);
494 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
495 if (file
== NULL
) return errFailed
;
498 int err
= slotIntVal(b
, &val
);
501 SC_IOStream
<FILE*> scio(file
);
502 scio
.writeInt32_be(val
);
507 int prFilePutInt16(struct VMGlobals
*g
, int numArgsPushed
)
516 pfile
= (PyrFile
*)slotRawObject(a
);
517 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
518 if (file
== NULL
) return errFailed
;
521 int err
= slotIntVal(b
, &val
);
525 SC_IOStream
<FILE*> scio(file
);
526 scio
.writeInt16_be(val
);
532 int prFilePutInt32LE(struct VMGlobals
*g
, int numArgsPushed
)
541 pfile
= (PyrFile
*)slotRawObject(a
);
542 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
543 if (file
== NULL
) return errFailed
;
546 int err
= slotIntVal(b
, &val
);
549 SC_IOStream
<FILE*> scio(file
);
550 scio
.writeInt32_le(val
);
555 int prFilePutInt16LE(struct VMGlobals
*g
, int numArgsPushed
)
564 pfile
= (PyrFile
*)slotRawObject(a
);
565 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
566 if (file
== NULL
) return errFailed
;
569 int err
= slotIntVal(b
, &val
);
573 SC_IOStream
<FILE*> scio(file
);
574 scio
.writeInt16_le(val
);
579 int prFilePutInt8(struct VMGlobals
*g
, int numArgsPushed
)
588 pfile
= (PyrFile
*)slotRawObject(a
);
589 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
590 if (file
== NULL
) return errFailed
;
593 int err
= slotIntVal(b
, &val
);
597 SC_IOStream
<FILE*> scio(file
);
603 int prFilePutChar(struct VMGlobals
*g
, int numArgsPushed
)
613 pfile
= (PyrFile
*)slotRawObject(a
);
614 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
615 if (file
== NULL
) return errFailed
;
616 if (NotChar(b
)) return errWrongType
;
620 SC_IOStream
<FILE*> scio(file
);
626 int prFilePutFloat(struct VMGlobals
*g
, int numArgsPushed
)
635 pfile
= (PyrFile
*)slotRawObject(a
);
636 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
643 int err
= slotFloatVal(b
, &val
);
646 SC_IOStream
<FILE*> scio(file
);
647 scio
.writeFloat_be(val
);
652 int prFilePutDouble(struct VMGlobals
*g
, int numArgsPushed
)
661 pfile
= (PyrFile
*)slotRawObject(a
);
662 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
663 if (file
== NULL
) return errFailed
;
667 int err
= slotDoubleVal(b
, &val
);
670 SC_IOStream
<FILE*> scio(file
);
671 scio
.writeDouble_be(val
);
677 int prFilePutFloatLE(struct VMGlobals
*g
, int numArgsPushed
)
686 pfile
= (PyrFile
*)slotRawObject(a
);
687 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
694 int err
= slotFloatVal(b
, &val
);
697 SC_IOStream
<FILE*> scio(file
);
698 scio
.writeFloat_le(val
);
703 int prFilePutDoubleLE(struct VMGlobals
*g
, int numArgsPushed
)
712 pfile
= (PyrFile
*)slotRawObject(a
);
713 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
714 if (file
== NULL
) return errFailed
;
718 int err
= slotDoubleVal(b
, &val
);
721 SC_IOStream
<FILE*> scio(file
);
722 scio
.writeDouble_le(val
);
727 int prFilePutString(struct VMGlobals
*g
, int numArgsPushed
)
736 pfile
= (PyrFile
*)slotRawObject(a
);
737 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
738 if (file
== NULL
) return errFailed
;
739 if (NotObj(b
) || slotRawObject(b
)->classptr
!= class_string
) return errWrongType
;
740 string
= slotRawString(b
);
742 fwrite(string
->s
, 1, string
->size
, file
);
748 int prFileGetDouble(struct VMGlobals
*g
, int numArgsPushed
)
756 pfile
= (PyrFile
*)slotRawObject(a
);
757 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
758 if (file
== NULL
) return errFailed
;
760 if (feof(file
)) SetNil(a
);
762 SC_IOStream
<FILE*> scio(file
);
763 SetFloat(a
, scio
.readDouble_be());
768 int prFileGetFloat(struct VMGlobals
*g
, int numArgsPushed
)
776 pfile
= (PyrFile
*)slotRawObject(a
);
777 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
778 if (file
== NULL
) return errFailed
;
780 if (feof(file
)) SetNil(a
);
782 SC_IOStream
<FILE*> scio(file
);
783 SetFloat(a
, scio
.readFloat_be());
789 int prFileGetDoubleLE(struct VMGlobals
*g
, int numArgsPushed
)
797 pfile
= (PyrFile
*)slotRawObject(a
);
798 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
799 if (file
== NULL
) return errFailed
;
801 if (feof(file
)) SetNil(a
);
803 SC_IOStream
<FILE*> scio(file
);
804 SetFloat(a
, scio
.readDouble_le());
809 int prFileGetFloatLE(struct VMGlobals
*g
, int numArgsPushed
)
817 pfile
= (PyrFile
*)slotRawObject(a
);
818 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
819 if (file
== NULL
) return errFailed
;
821 if (feof(file
)) SetNil(a
);
823 SC_IOStream
<FILE*> scio(file
);
824 SetFloat(a
, scio
.readFloat_le());
829 int prFileGetChar(struct VMGlobals
*g
, int numArgsPushed
)
838 pfile
= (PyrFile
*)slotRawObject(a
);
839 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
840 if (file
== NULL
) return errFailed
;
842 int count
= fread(&z
, sizeof(char), 1, file
);
843 if (count
==0) SetNil(a
);
848 int prFileGetInt8(struct VMGlobals
*g
, int numArgsPushed
)
857 pfile
= (PyrFile
*)slotRawObject(a
);
858 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
859 if (file
== NULL
) return errFailed
;
861 int count
= fread(&z
, sizeof(char), 1, file
);
862 if (count
==0) SetNil(a
);
867 int prFileGetInt16(struct VMGlobals
*g
, int numArgsPushed
)
875 pfile
= (PyrFile
*)slotRawObject(a
);
876 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
877 if (file
== NULL
) return errFailed
;
879 if (feof(file
)) SetNil(a
);
881 SC_IOStream
<FILE*> scio(file
);
882 SetInt(a
, scio
.readInt16_be());
887 int prFileGetInt32(struct VMGlobals
*g
, int numArgsPushed
)
895 pfile
= (PyrFile
*)slotRawObject(a
);
896 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
900 if (feof(file
)) SetNil(a
);
902 SC_IOStream
<FILE*> scio(file
);
903 SetInt(a
, scio
.readInt32_be());
909 int prFileGetInt16LE(struct VMGlobals
*g
, int numArgsPushed
)
917 pfile
= (PyrFile
*)slotRawObject(a
);
918 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
919 if (file
== NULL
) return errFailed
;
921 if (feof(file
)) SetNil(a
);
923 SC_IOStream
<FILE*> scio(file
);
924 SetInt(a
, scio
.readInt16_le());
929 int prFileGetInt32LE(struct VMGlobals
*g
, int numArgsPushed
)
937 pfile
= (PyrFile
*)slotRawObject(a
);
938 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
939 if (file
== NULL
) return errFailed
;
941 if (feof(file
)) SetNil(a
);
943 SC_IOStream
<FILE*> scio(file
);
944 SetInt(a
, scio
.readInt32_le());
949 int prFileReadRaw(struct VMGlobals
*g
, int numArgsPushed
)
954 PyrSlot
* a
= g
->sp
- 1;
957 if (!isKindOfSlot(b
, class_rawarray
)
958 || isKindOfSlot(b
, class_symbolarray
)) return errWrongType
;
960 pfile
= (PyrFile
*)slotRawObject(a
);
961 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
962 if (file
== NULL
) return errFailed
;
964 int elemSize
= gFormatElemSize
[slotRawObject(b
)->obj_format
];
965 int numElems
= slotRawObject(b
)->size
;
966 numElems
= fread(slotRawString(b
)->s
, elemSize
, numElems
, file
);
967 slotRawObject(b
)->size
= numElems
;
969 #if BYTE_ORDER != BIG_ENDIAN
975 char *ptr
= slotRawString(b
)->s
;
976 char *ptrend
= ptr
+ numElems
*2;
977 for (; ptr
< ptrend
; ptr
+=2) {
986 char *ptr
= slotRawString(b
)->s
;
987 char *ptrend
= ptr
+ numElems
*4;
988 for (; ptr
< ptrend
; ptr
+=4) {
1001 char *ptr
= slotRawString(b
)->s
;
1002 char *ptrend
= ptr
+ numElems
*8;
1003 for (; ptr
< ptrend
; ptr
+=8) {
1025 if (slotRawObject(b
)->size
==0) SetNil(a
);
1030 int prFileReadRawLE(struct VMGlobals
*g
, int numArgsPushed
)
1035 PyrSlot
* a
= g
->sp
- 1;
1038 if (!isKindOfSlot(b
, class_rawarray
)
1039 || isKindOfSlot(b
, class_symbolarray
)) return errWrongType
;
1041 pfile
= (PyrFile
*)slotRawObject(a
);
1042 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
1043 if (file
== NULL
) return errFailed
;
1045 int elemSize
= gFormatElemSize
[slotRawObject(b
)->obj_format
];
1046 int numElems
= slotRawObject(b
)->size
;
1047 numElems
= fread(slotRawString(b
)->s
, elemSize
, numElems
, file
);
1048 slotRawObject(b
)->size
= numElems
;
1050 #if BYTE_ORDER == BIG_ENDIAN
1056 char *ptr
= slotRawString(b
)->s
;
1057 char *ptrend
= ptr
+ numElems
*2;
1058 for (; ptr
< ptrend
; ptr
+=2) {
1067 char *ptr
= slotRawString(b
)->s
;
1068 char *ptrend
= ptr
+ numElems
*4;
1069 for (; ptr
< ptrend
; ptr
+=4) {
1082 char *ptr
= slotRawString(b
)->s
;
1083 char *ptrend
= ptr
+ numElems
*8;
1084 for (; ptr
< ptrend
; ptr
+=8) {
1106 if (slotRawObject(b
)->size
==0) SetNil(a
);
1111 int prFileGetcwd(struct VMGlobals
*g
, int numArgsPushed
)
1113 //PyrSlot* a = g->sp - 1; // File
1114 PyrSlot
* string
= g
->sp
;
1116 if (!isKindOfSlot(string
, class_string
)) return errWrongType
;
1118 char * cwd
= getcwd(slotRawString(string
)->s
,255);
1120 error(strerror(errno
));
1123 slotRawString(string
)->size
= strlen(slotRawString(string
)->s
);
1131 int prPipeOpen(struct VMGlobals
*g
, int numArgsPushed
)
1142 if (NotObj(c
) || !isKindOf(slotRawObject(c
), class_string
)
1143 || NotObj(b
) || !isKindOf(slotRawObject(b
), class_string
))
1144 return errWrongType
;
1145 if (slotRawObject(c
)->size
> 11) return errFailed
;
1146 pfile
= (PyrFile
*)slotRawObject(a
);
1148 char *commandLine
= (char*)malloc(slotRawObject(b
)->size
+ 1);
1149 memcpy(commandLine
, slotRawString(b
)->s
, slotRawObject(b
)->size
);
1150 commandLine
[slotRawString(b
)->size
] = 0;
1152 memcpy(mode
, slotRawString(c
)->s
, slotRawObject(c
)->size
);
1153 mode
[slotRawString(c
)->size
] = 0;
1155 file
= popen(commandLine
, mode
);
1158 SetPtr(&pfile
->fileptr
, file
);
1167 int prPipeClose(struct VMGlobals
*g
, int numArgsPushed
)
1174 pfile
= (PyrFile
*)slotRawObject(a
);
1175 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
1176 if (file
== NULL
) return errNone
;
1177 SetPtr(&pfile
->fileptr
, NULL
);
1178 int perr
= pclose(file
);
1188 #ifndef NO_LIBSNDFILE
1191 #include <sndfile-win.h>
1193 #include <sndfile.h>
1197 int sampleFormatToString(struct SF_INFO
*info
, const char **string
);
1198 int sampleFormatToString(struct SF_INFO
*info
, const char **string
)
1200 unsigned int format
= info
->format
& SF_FORMAT_SUBMASK
;
1203 case SF_FORMAT_DPCM_8
:
1204 case SF_FORMAT_PCM_S8
:
1207 case SF_FORMAT_DPCM_16
:
1208 case SF_FORMAT_PCM_16
:
1209 case SF_FORMAT_DWVW_16
:
1212 case SF_FORMAT_PCM_24
:
1213 case SF_FORMAT_DWVW_24
:
1216 case SF_FORMAT_PCM_32
:
1219 case SF_FORMAT_FLOAT
:
1222 case SF_FORMAT_DOUBLE
:
1225 case SF_FORMAT_ULAW
:
1228 case SF_FORMAT_ALAW
:
1239 int headerFormatToString(struct SF_INFO
*info
, const char **string
);
1240 int headerFormatToString(struct SF_INFO
*info
, const char **string
){
1241 switch (info
->format
& SF_FORMAT_TYPEMASK
)
1243 case SF_FORMAT_WAV
:
1246 case SF_FORMAT_AIFF
:
1252 case SF_FORMAT_IRCAM
:
1255 case SF_FORMAT_RAW
:
1258 case SF_FORMAT_W64
:
1261 case SF_FORMAT_FLAC
:
1264 // TODO allow other platforms to know vorbis once libsndfile 1.0.18 is established
1265 #if SC_DARWIN || SC_WIN32 || LIBSNDFILE_1018
1266 case SF_FORMAT_VORBIS
:
1271 case SF_FORMAT_PAF :
1275 case SF_FORMAT_SVX :
1279 case SF_FORMAT_NIST :
1283 case SF_FORMAT_VOC :
1287 case SF_FORMAT_MAT4 :
1291 case SF_FORMAT_MAT5 :
1295 case SF_FORMAT_PVF :
1303 case SF_FORMAT_HTK :
1307 case SF_FORMAT_SDS :
1318 int sndfileFormatInfoToStrings(struct SF_INFO
*info
, const char **stringHead
, const char **stringSample
);
1319 int sndfileFormatInfoToStrings(struct SF_INFO
*info
, const char **stringHead
, const char **stringSample
)
1322 error
= headerFormatToString(info
, stringHead
);
1323 error
= sampleFormatToString(info
, stringSample
);
1327 int prSFOpenRead(struct VMGlobals
*g
, int numArgsPushed
);
1328 int prSFOpenRead(struct VMGlobals
*g
, int numArgsPushed
)
1331 char filename
[PATH_MAX
];
1334 const char *headerstr
;
1335 const char *sampleformatstr
;
1340 if (!isKindOfSlot(b
, class_string
)) return errWrongType
;
1341 if (slotRawObject(b
)->size
> PATH_MAX
- 1) return errFailed
;
1343 memcpy(filename
, slotRawString(b
)->s
, slotRawObject(b
)->size
);
1344 filename
[slotRawString(b
)->size
] = 0;
1347 file
= sf_open(filename
, SFM_READ
, &info
);
1351 SetPtr(slotRawObject(a
)->slots
+ 0, file
);
1352 sndfileFormatInfoToStrings(&info
, &headerstr
, &sampleformatstr
);
1353 //headerFormatToString(&info, &headerstr);
1354 PyrString
*hpstr
= newPyrString(g
->gc
, headerstr
, 0, true);
1355 SetObject(slotRawObject(a
)->slots
+1, hpstr
);
1356 PyrString
*smpstr
= newPyrString(g
->gc
, sampleformatstr
, 0, true);
1357 SetObject(slotRawObject(a
)->slots
+2, smpstr
);
1358 SetInt(slotRawObject(a
)->slots
+ 3, info
.frames
);
1359 SetInt(slotRawObject(a
)->slots
+ 4, info
.channels
);
1360 SetInt(slotRawObject(a
)->slots
+ 5, info
.samplerate
);
1369 /// copied from SC_World.cpp:
1371 int sampleFormatFromString(const char* name
);
1372 int sampleFormatFromString(const char* name
)
1374 if (!name
) return SF_FORMAT_PCM_16
;
1376 size_t len
= strlen(name
);
1377 if (len
< 1) return 0;
1379 if (name
[0] == 'u') {
1380 if (len
< 5) return 0;
1381 if (name
[4] == '8') return SF_FORMAT_PCM_U8
; // uint8
1383 } else if (name
[0] == 'i') {
1384 if (len
< 4) return 0;
1385 if (name
[3] == '8') return SF_FORMAT_PCM_S8
; // int8
1386 else if (name
[3] == '1') return SF_FORMAT_PCM_16
; // int16
1387 else if (name
[3] == '2') return SF_FORMAT_PCM_24
; // int24
1388 else if (name
[3] == '3') return SF_FORMAT_PCM_32
; // int32
1389 } else if (name
[0] == 'f') {
1390 return SF_FORMAT_FLOAT
; // float
1391 } else if (name
[0] == 'd') {
1392 return SF_FORMAT_DOUBLE
; // double
1393 } else if (name
[0] == 'm' || name
[0] == 'u') {
1394 return SF_FORMAT_ULAW
; // mulaw ulaw
1395 } else if (name
[0] == 'a') {
1396 return SF_FORMAT_ALAW
; // alaw
1401 int headerFormatFromString(const char *name
);
1402 int headerFormatFromString(const char *name
)
1404 if (!name
) return SF_FORMAT_AIFF
;
1405 if (strcasecmp(name
, "AIFF")==0) return SF_FORMAT_AIFF
;
1406 if (strcasecmp(name
, "AIFC")==0) return SF_FORMAT_AIFF
;
1407 if (strcasecmp(name
, "RIFF")==0) return SF_FORMAT_WAV
;
1408 if (strcasecmp(name
, "WAVEX")==0) return SF_FORMAT_WAVEX
;
1409 if (strcasecmp(name
, "WAVE")==0) return SF_FORMAT_WAV
;
1410 if (strcasecmp(name
, "WAV" )==0) return SF_FORMAT_WAV
;
1411 if (strcasecmp(name
, "Sun" )==0) return SF_FORMAT_AU
;
1412 if (strcasecmp(name
, "IRCAM")==0) return SF_FORMAT_IRCAM
;
1413 if (strcasecmp(name
, "NeXT")==0) return SF_FORMAT_AU
;
1414 if (strcasecmp(name
, "raw")==0) return SF_FORMAT_RAW
;
1415 if (strcasecmp(name
, "MAT4")==0) return SF_FORMAT_MAT4
;
1416 if (strcasecmp(name
, "MAT5")==0) return SF_FORMAT_MAT5
;
1417 if (strcasecmp(name
, "PAF")==0) return SF_FORMAT_PAF
;
1418 if (strcasecmp(name
, "SVX")==0) return SF_FORMAT_SVX
;
1419 if (strcasecmp(name
, "NIST")==0) return SF_FORMAT_NIST
;
1420 if (strcasecmp(name
, "VOC")==0) return SF_FORMAT_VOC
;
1421 if (strcasecmp(name
, "W64")==0) return SF_FORMAT_W64
;
1422 if (strcasecmp(name
, "PVF")==0) return SF_FORMAT_PVF
;
1423 if (strcasecmp(name
, "XI")==0) return SF_FORMAT_XI
;
1424 if (strcasecmp(name
, "HTK")==0) return SF_FORMAT_HTK
;
1425 if (strcasecmp(name
, "SDS")==0) return SF_FORMAT_SDS
;
1426 if (strcasecmp(name
, "AVR")==0) return SF_FORMAT_AVR
;
1427 if (strcasecmp(name
, "SD2")==0) return SF_FORMAT_SD2
;
1428 if (strcasecmp(name
, "FLAC")==0) return SF_FORMAT_FLAC
;
1429 if (strcasecmp(name
, "CAF")==0) return SF_FORMAT_CAF
;
1430 // TODO allow other platforms to know vorbis once libsndfile 1.0.18 is established
1431 #if SC_DARWIN || SC_WIN32
1432 if (strcasecmp(name
, "VORBIS")==0) return SF_FORMAT_VORBIS
;
1438 int sndfileFormatInfoFromStrings(struct SF_INFO
*info
, const char *headerFormatString
, const char *sampleFormatString
)
1440 int headerFormat
= headerFormatFromString(headerFormatString
);
1441 if (!headerFormat
) return errWrongType
;
1443 int sampleFormat
= sampleFormatFromString(sampleFormatString
);
1444 if (!sampleFormat
) return errWrongType
;
1446 info
->format
= (unsigned int)(headerFormat
| sampleFormat
);
1451 int prSFOpenWrite(struct VMGlobals
*g
, int numArgsPushed
);
1452 int prSFOpenWrite(struct VMGlobals
*g
, int numArgsPushed
)
1455 char filename
[PATH_MAX
];
1458 PyrSlot
*headerSlot
;
1459 PyrSlot
*formatSlot
;
1466 headerSlot
= (slotRawObject(a
)->slots
+ 1);
1467 formatSlot
= (slotRawObject(a
)->slots
+ 2);
1470 if (!isKindOfSlot(headerSlot
, class_string
)) return errWrongType
;
1471 if (!isKindOfSlot(formatSlot
, class_string
)) return errWrongType
;
1473 if (!isKindOfSlot(b
, class_string
)) return errWrongType
;
1474 if (slotRawObject(b
)->size
> PATH_MAX
- 1) return errFailed
;
1476 memcpy(filename
, slotRawString(b
)->s
, slotRawObject(b
)->size
);
1477 filename
[slotRawString(b
)->size
] = 0;
1480 char* headerFormat
= (char *)malloc(slotRawObject(headerSlot
)->size
);
1482 char headerFormat
[slotRawString(headerSlot
)->size
];
1484 memcpy(headerFormat
, slotRawString(headerSlot
)->s
, slotRawObject(headerSlot
)->size
);
1485 headerFormat
[slotRawString(headerSlot
)->size
] = 0;
1488 char* sampleFormat
= (char *)malloc(slotRawString(formatSlot
)->size
);
1490 char sampleFormat
[slotRawString(formatSlot
)->size
];
1492 memcpy(sampleFormat
, slotRawString(formatSlot
)->s
, slotRawObject(formatSlot
)->size
);
1493 sampleFormat
[slotRawString(formatSlot
)->size
] = 0;
1495 error
= sndfileFormatInfoFromStrings(&info
, headerFormat
, sampleFormat
);
1504 if(error
) return errFailed
;
1505 //slotIntVal(slotRawObject(a)->slots + 3, &info.frames);
1506 slotIntVal(slotRawObject(a
)->slots
+ 4, &info
.channels
);
1507 slotIntVal(slotRawObject(a
)->slots
+ 5, &info
.samplerate
);
1509 file
= sf_open(filename
, SFM_WRITE
, &info
);
1511 SetPtr(slotRawObject(a
)->slots
+0, file
);
1521 int prSFClose(struct VMGlobals
*g
, int numArgsPushed
);
1522 int prSFClose(struct VMGlobals
*g
, int numArgsPushed
)
1528 SNDFILE
*file
= (SNDFILE
*)slotRawPtr(&slotRawObject(a
)->slots
[0]);
1531 SetNil(slotRawObject(a
)->slots
+ 0);
1537 int prSFRead(struct VMGlobals
*g
, int numArgsPushed
);
1538 int prSFRead(struct VMGlobals
*g
, int numArgsPushed
)
1545 SNDFILE
*file
= (SNDFILE
*)slotRawPtr(&slotRawObject(a
)->slots
[0]);
1547 if (!isKindOfSlot(b
, class_rawarray
)) return errWrongType
;
1549 switch (slotRawObject(b
)->obj_format
) {
1551 slotRawObject(b
)->size
= sf_read_short(file
, (short*)slotRawInt8Array(b
)->b
, slotRawObject(b
)->size
);
1554 slotRawObject(b
)->size
= sf_read_int(file
, (int*)slotRawInt8Array(b
)->b
, slotRawObject(b
)->size
);
1557 slotRawObject(b
)->size
= sf_read_float(file
, (float*)slotRawInt8Array(b
)->b
, slotRawObject(b
)->size
);
1560 slotRawObject(b
)->size
= sf_read_double(file
, (double*)slotRawInt8Array(b
)->b
, slotRawObject(b
)->size
);
1563 error("sample format not supported.\n");
1570 int prSFWrite(struct VMGlobals
*g
, int numArgsPushed
);
1571 int prSFWrite(struct VMGlobals
*g
, int numArgsPushed
)
1578 SNDFILE
*file
= (SNDFILE
*)slotRawPtr(&slotRawObject(a
)->slots
[0]);
1580 if (!isKindOfSlot(b
, class_rawarray
)) return errWrongType
;
1582 switch (slotRawObject(b
)->obj_format
) {
1584 sf_write_short(file
, (short*)slotRawInt8Array(b
)->b
, slotRawObject(b
)->size
);
1587 sf_write_int(file
, (int*)slotRawInt8Array(b
)->b
, slotRawObject(b
)->size
);
1590 sf_write_float(file
, (float*)slotRawInt8Array(b
)->b
, slotRawObject(b
)->size
);
1593 sf_write_double(file
, (double*)slotRawInt8Array(b
)->b
, slotRawObject(b
)->size
);
1596 error("sample format not supported.\n");
1603 int prSFSeek(struct VMGlobals
*g
, int numArgsPushed
);
1604 int prSFSeek(struct VMGlobals
*g
, int numArgsPushed
)
1612 SNDFILE
*file
= (SNDFILE
*)slotRawPtr(&slotRawObject(a
)->slots
[0]);
1615 int err
= slotIntVal(b
, &offset
);
1616 if (err
) return err
;
1618 err
= slotIntVal(c
, &origin
);
1619 if (err
) return err
;
1621 sf_seek(file
, offset
, origin
);
1626 int prSFHeaderInfoString(struct VMGlobals
*g
, int numArgsPushed
);
1627 int prSFHeaderInfoString(struct VMGlobals
*g
, int numArgsPushed
)
1632 SNDFILE
*file
= (SNDFILE
*)slotRawPtr(&slotRawObject(a
)->slots
[0]);
1634 static char strbuffer
[(1 << 16)] ;
1635 sf_command (file
, SFC_GET_LOG_INFO
, strbuffer
, (1 << 16)) ;
1636 PyrString
*pstring
= newPyrString(g
->gc
, strbuffer
, 0, true);
1638 SetObject(a
, pstring
);
1644 #else // !NO_LIBSNDFILE
1646 int prSFOpenRead(struct VMGlobals
*g
, int numArgsPushed
)
1651 int prSFOpenWrite(struct VMGlobals
*g
, int numArgsPushed
)
1656 int prSFClose(struct VMGlobals
*g
, int numArgsPushed
)
1661 int prSFWrite(struct VMGlobals
*g
, int numArgsPushed
)
1666 int prSFRead(struct VMGlobals
*g
, int numArgsPushed
)
1671 int prSFSeek(struct VMGlobals
*g
, int numArgsPushed
)
1676 int prSFHeaderInfoString(struct VMGlobals
*g
, int numArgsPushed
)
1681 #endif // !NO_LIBSNDFILE
1687 int dir_Lookup(char *pathString
, int pathStringLength
, int index
,
1689 char *name
, int *nameLength
, int *creationDate
, int *modificationDate
,
1690 int *isDirectory
, int *isVisible
, int *sizeIfFile
);
1692 int prDirectory_At(struct VMGlobals
*g
, int numArgsPushed
);
1693 int prDirectory_At(struct VMGlobals
*g
, int numArgsPushed
)
1695 PyrSlot
*a
= g
->sp
- 2;
1696 PyrSlot
*b
= g
->sp
- 1;
1699 PyrSlot
*dirPathSlot
= slotRawObject(a
)->slots
+ 0;
1701 err
= slotIntVal(c
, &index
);
1707 char name
[256], fullPathName
[256];
1708 int nameLength
, creationDate
, modificationDate
, isDirectory
, isVisible
, sizeIfFile
;
1709 int dirPathLength
= slotRawObject(dirPathSlot
)->size
;
1711 err
= dir_Lookup(slotRawObject(dirPathSlot
)s
->s
, dirPathLength
, index
+1,
1712 name
, &nameLength
, &creationDate
, &modificationDate
, &isDirectory
, &isVisible
, &sizeIfFile
);
1718 error("Invalid path\n");
1723 if (dirPathLength
+ nameLength
+ 1 > 255) {
1724 error("Full path name too long.\n");
1729 PyrSlot
*entryName
= slotRawObject(b
)->slots
+ 0;
1730 PyrSlot
*entryPath
= slotRawObject(b
)->slots
+ 1;
1731 PyrSlot
*entryIsDir
= slotRawObject(b
)->slots
+ 2;
1732 PyrSlot
*entryIsVisible
= slotRawObject(b
)->slots
+ 3;
1734 PyrString
*nameString
= newPyrString(g
->gc
, name
, 0, true);
1735 SetObject(entryName
, nameString
);
1736 g
->gc
->GCWrite(slotRawObject(b
), (PyrObject
*)nameString
);
1738 memcpy(fullPathName
, slotRawObject(dirPathSlot
)s
->s
, dirPathLength
);
1739 fullPathName
[dirPathLength
] = DELIMITOR
;
1740 strcpy(fullPathName
+ dirPathLength
+ 1, name
);
1742 PyrString
*pathString
= newPyrString(g
->gc
, fullPathName
, 0, true);
1743 SetObject(entryPath
, pathString
);
1744 g
->gc
->GCWrite(slotRawObject(b
), (PyrObject
*)pathString
);
1746 if (isDirectory
) { SetTrue(entryIsDir
); } else { SetFalse(entryIsDir
); }
1747 if (isVisible
) { SetTrue(entryIsVisible
); } else { SetFalse(entryIsVisible
); }
1754 Boolean
GetFullPathname(const FSSpec
* aSpec
, Str255 pathname
);
1755 void pstrncpy(unsigned char *s1
, unsigned char *s2
, int n
);
1757 int prFile_GetFile(struct VMGlobals
*g
, int numArgsPushed
);
1758 int prFile_GetFile(struct VMGlobals
*g
, int numArgsPushed
)
1761 PyrSlot
*a
= g
->sp
- 1;
1764 NavDialogOptions options
;
1766 int err
= NavGetDefaultDialogOptions(&options
);
1767 if (err
) return errFailed
;
1769 options
.dialogOptionFlags
|= kNavNoTypePopup
;
1770 options
.dialogOptionFlags
|= kNavDontAutoTranslate
;
1771 options
.dialogOptionFlags
|= kNavDontAddTranslateItems
;
1772 options
.dialogOptionFlags
|= kNavSelectDefaultLocation
;
1773 options
.dialogOptionFlags
&= ~kNavAllowPreviews
;
1774 options
.dialogOptionFlags
&= ~kNavAllowMultipleFiles
;
1776 if (isKindOfSlot(b
, class_string
)) {
1777 pstringFromPyrString((PyrString
*)slotRawObject(b
), options
.message
, 256);
1780 NavReplyRecord reply
;
1781 err
= NavGetFile(0, &reply
, &options
, 0, 0, 0, 0, 0);
1783 if (err
== noErr
&& reply
.validRecord
) {
1785 DescType actualType
;
1789 err
= AEGetNthPtr(&reply
.selection
, 1, typeFSS
, &keyword
, &actualType
,
1790 &fsspec
, sizeof(FSSpec
), &actualSize
);
1794 GetFullPathname(&fsspec
, pathname
);
1796 PyrString
*string
= newPyrString(g
->gc
, (char*)pathname
, 0, true);
1797 SetObject(a
, string
);
1801 err
= NavDisposeReply(&reply
);
1810 int prFile_PutFile(struct VMGlobals
*g
, int numArgsPushed
);
1811 int prFile_PutFile(struct VMGlobals
*g
, int numArgsPushed
)
1814 PyrSlot
*a
= g
->sp
- 2;
1815 PyrSlot
*b
= g
->sp
- 1;
1818 NavDialogOptions options
;
1820 int err
= NavGetDefaultDialogOptions(&options
);
1821 if (err
) return errFailed
;
1823 options
.dialogOptionFlags
|= kNavNoTypePopup
;
1824 options
.dialogOptionFlags
|= kNavDontAutoTranslate
;
1825 options
.dialogOptionFlags
|= kNavDontAddTranslateItems
;
1826 options
.dialogOptionFlags
|= kNavSelectDefaultLocation
;
1827 options
.dialogOptionFlags
&= ~kNavAllowPreviews
;
1828 options
.dialogOptionFlags
&= ~kNavAllowMultipleFiles
;
1830 if (isKindOfSlot(b
, class_string
)) {
1831 pstringFromPyrString((PyrString
*)slotRawObject(b
), options
.message
, 256);
1834 if (isKindOfSlot(c
, class_string
)) {
1835 pstringFromPyrString((PyrString
*)slotRawObject(c
), options
.savedFileName
, 256);
1837 //pstrncpy(options.savedFileName, "\pUntitled", 255);
1840 NavReplyRecord reply
;
1841 err
= NavPutFile(0, &reply
, &options
, 0, 'TEXT', 'SCjm', 0);
1843 if (err
== noErr
&& reply
.validRecord
) {
1845 DescType actualType
;
1849 err
= AEGetNthPtr(&reply
.selection
, 1, typeFSS
, &keyword
, &actualType
,
1850 &fsspec
, sizeof(FSSpec
), &actualSize
);
1854 GetFullPathname(&fsspec
, pathname
);
1856 PyrString
*string
= newPyrString(g
->gc
, (char*)pathname
, 0, true);
1857 SetObject(a
, string
);
1859 err
= NavCompleteSave(&reply
, kNavTranslateInPlace
);
1863 err
= NavDisposeReply(&reply
);
1874 void initFilePrimitives()
1878 base
= nextPrimitiveIndex();
1881 definePrimitive(base
, index
++, "_SFOpenRead", prSFOpenRead
, 2, 0);
1882 definePrimitive(base
, index
++, "_SFOpenWrite", prSFOpenWrite
, 2, 0);
1883 definePrimitive(base
, index
++, "_SFClose", prSFClose
, 1, 0);
1884 definePrimitive(base
, index
++, "_SFWrite", prSFWrite
, 2, 0);
1885 definePrimitive(base
, index
++, "_SFRead", prSFRead
, 2, 0);
1886 definePrimitive(base
, index
++, "_SFSeek", prSFSeek
, 3, 0);
1887 definePrimitive(base
, index
++, "_SFHeaderInfoString", prSFHeaderInfoString
, 1, 0);
1890 definePrimitive(base
, index
++, "_PipeOpen", prPipeOpen
, 3, 0);
1891 definePrimitive(base
, index
++, "_PipeClose", prPipeClose
, 1, 0);
1894 definePrimitive(base
, index
++, "_FileDelete", prFileDelete
, 2, 0);
1895 definePrimitive(base
, index
++, "_FileOpen", prFileOpen
, 3, 0);
1896 definePrimitive(base
, index
++, "_FileClose", prFileClose
, 1, 0);
1897 definePrimitive(base
, index
++, "_FileFlush", prFileFlush
, 1, 0);
1898 definePrimitive(base
, index
++, "_FileSeek", prFileSeek
, 3, 0);
1899 definePrimitive(base
, index
++, "_FilePos", prFilePos
, 1, 0);
1900 definePrimitive(base
, index
++, "_FileLength", prFileLength
, 1, 0);
1901 definePrimitive(base
, index
++, "_FileWrite", prFileWrite
, 2, 0);
1902 definePrimitive(base
, index
++, "_FileWriteLE", prFileWriteLE
, 2, 0);
1903 definePrimitive(base
, index
++, "_FileReadLine", prFileReadLine
, 2, 0);
1904 definePrimitive(base
, index
++, "_File_getcwd", prFileGetcwd
, 2, 0);
1906 definePrimitive(base
, index
++, "_FilePutChar", prFilePutChar
, 2, 0);
1907 definePrimitive(base
, index
++, "_FilePutInt8", prFilePutInt8
, 2, 0);
1908 definePrimitive(base
, index
++, "_FilePutInt16", prFilePutInt16
, 2, 0);
1909 definePrimitive(base
, index
++, "_FilePutInt32", prFilePutInt32
, 2, 0);
1910 definePrimitive(base
, index
++, "_FilePutFloat", prFilePutFloat
, 2, 0);
1911 definePrimitive(base
, index
++, "_FilePutDouble", prFilePutDouble
, 2, 0);
1912 definePrimitive(base
, index
++, "_FilePutInt16LE", prFilePutInt16LE
, 2, 0);
1913 definePrimitive(base
, index
++, "_FilePutInt32LE", prFilePutInt32LE
, 2, 0);
1914 definePrimitive(base
, index
++, "_FilePutFloatLE", prFilePutFloatLE
, 2, 0);
1915 definePrimitive(base
, index
++, "_FilePutDoubleLE", prFilePutDoubleLE
, 2, 0);
1917 definePrimitive(base
, index
++, "_FileGetChar", prFileGetChar
, 1, 0);
1918 definePrimitive(base
, index
++, "_FileGetInt8", prFileGetInt8
, 1, 0);
1919 definePrimitive(base
, index
++, "_FileGetInt16", prFileGetInt16
, 1, 0);
1920 definePrimitive(base
, index
++, "_FileGetInt32", prFileGetInt32
, 1, 0);
1921 definePrimitive(base
, index
++, "_FileGetFloat", prFileGetFloat
, 1, 0);
1922 definePrimitive(base
, index
++, "_FileGetDouble", prFileGetDouble
, 1, 0);
1923 definePrimitive(base
, index
++, "_FileGetInt16LE", prFileGetInt16LE
, 1, 0);
1924 definePrimitive(base
, index
++, "_FileGetInt32LE", prFileGetInt32LE
, 1, 0);
1925 definePrimitive(base
, index
++, "_FileGetFloatLE", prFileGetFloatLE
, 1, 0);
1926 definePrimitive(base
, index
++, "_FileGetDoubleLE", prFileGetDoubleLE
, 1, 0);
1928 definePrimitive(base
, index
++, "_FilePutString", prFilePutString
, 2, 0);
1930 definePrimitive(base
, index
++, "_FileReadRaw", prFileReadRaw
, 2, 0);
1931 definePrimitive(base
, index
++, "_FileReadRawLE", prFileReadRawLE
, 2, 0);
1934 definePrimitive(base
, index
++, "_Directory_At", prDirectory_At
, 3, 0);
1935 definePrimitive(base
, index
++, "_File_GetFile", prFile_GetFile
, 2, 0);
1936 definePrimitive(base
, index
++, "_File_PutFile", prFile_PutFile
, 3, 0);