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 "ReadWriteMacros.h"
34 #include "SC_DirUtils.h"
42 #include "../../common/SC_SndFileHelpers.hpp"
45 #include <TextUtils.h>
46 #include <Navigation.h>
58 #include "SC_Win32Utils.h"
59 #include "SC_DirUtils.h"
65 #include <boost/filesystem.hpp>
67 #if defined(__APPLE__) || defined(SC_IPHONE)
68 #ifndef _SC_StandAloneInfo_
69 # include "SC_StandAloneInfo_Darwin.h"
71 # include <CoreFoundation/CFString.h>
72 # include <CoreFoundation/CFBundle.h>
74 # include <CoreServices/CoreServices.h>
80 int prFileDelete(struct VMGlobals
*g
, int numArgsPushed
)
82 PyrSlot
*a
= g
->sp
- 1, *b
= g
->sp
;
83 char filename
[PATH_MAX
];
85 int error
= slotStrVal(b
, filename
, PATH_MAX
);
89 int err
= unlink(filename
);
95 int prFileMTime(struct VMGlobals
* g
, int numArgsPushed
)
97 PyrSlot
*a
= g
->sp
- 1, *b
= g
->sp
;
98 char filename
[PATH_MAX
];
100 int error
= slotStrVal(b
, filename
, PATH_MAX
);
101 if (error
!= errNone
)
104 time_t mtime
= boost::filesystem::last_write_time(filename
);
109 int prFileExists(struct VMGlobals
* g
, int numArgsPushed
)
111 PyrSlot
*a
= g
->sp
- 1, *b
= g
->sp
;
112 char filename
[PATH_MAX
];
114 int error
= slotStrVal(b
, filename
, PATH_MAX
);
115 if (error
!= errNone
)
118 bool res
= boost::filesystem::exists(filename
);
123 int prFileRealPath(struct VMGlobals
* g
, int numArgsPushed
)
125 PyrSlot
*a
= g
->sp
- 1, *b
= g
->sp
;
126 char ipath
[PATH_MAX
];
127 char opath
[PATH_MAX
];
130 err
= slotStrVal(b
, ipath
, PATH_MAX
);
133 bool isAlias
= false;
134 if(sc_ResolveIfAlias(ipath
, opath
, isAlias
, PATH_MAX
)!=0) {
138 boost::system::error_code error_code
;
139 boost::filesystem::path p
= boost::filesystem::canonical(opath
,error_code
);
144 strcpy(opath
,p
.string().c_str());
147 CFStringRef cfstring
=
148 CFStringCreateWithCString(NULL
,
150 kCFStringEncodingUTF8
);
151 err
= !CFStringGetFileSystemRepresentation(cfstring
, opath
, PATH_MAX
);
153 if (err
) return errFailed
;
156 PyrString
* pyrString
= newPyrString(g
->gc
, opath
, 0, true);
157 SetObject(a
, pyrString
);
162 int prFileMkDir(struct VMGlobals
* g
, int numArgsPushed
)
165 char filename
[PATH_MAX
];
167 int error
= slotStrVal(b
, filename
, PATH_MAX
);
168 if (error
!= errNone
)
171 boost::system::error_code error_code
;
172 boost::filesystem::create_directories(filename
, error_code
);
174 postfl("Warning: %s (\"%s\")\n", error_code
.message().c_str(), filename
);
179 int prFileCopy(struct VMGlobals
* g
, int numArgsPushed
)
181 PyrSlot
*b
= g
->sp
- 1, *c
= g
->sp
;
182 char filename1
[PATH_MAX
];
183 char filename2
[PATH_MAX
];
185 error
= slotStrVal(b
, filename1
, PATH_MAX
);
186 if (error
!= errNone
)
188 error
= slotStrVal(c
, filename2
, PATH_MAX
);
189 if (error
!= errNone
)
192 boost::filesystem::copy(filename1
, filename2
);
196 int prFileType(struct VMGlobals
* g
, int numArgsPushed
)
198 PyrSlot
*a
= g
->sp
- 1, *b
= g
->sp
;
199 char filename
[PATH_MAX
];
201 int error
= slotStrVal(b
, filename
, PATH_MAX
);
202 if (error
!= errNone
)
205 boost::filesystem::file_status
s(boost::filesystem::symlink_status(filename
));
210 int prFileSize(struct VMGlobals
* g
, int numArgsPushed
)
212 PyrSlot
*a
= g
->sp
- 1, *b
= g
->sp
;
213 char filename
[PATH_MAX
];
215 int error
= slotStrVal(b
, filename
, PATH_MAX
);
216 if (error
!= errNone
)
219 uintmax_t sz
= boost::filesystem::file_size(filename
);
225 int prFileOpen(struct VMGlobals
*g
, int numArgsPushed
)
228 char filename
[PATH_MAX
];
236 if (NotObj(c
) || !isKindOf(slotRawObject(c
), class_string
)
237 || NotObj(b
) || !isKindOf(slotRawObject(b
), class_string
))
239 if (slotRawObject(b
)->size
> PATH_MAX
- 1) return errFailed
;
240 if (slotRawObject(c
)->size
> 11) return errFailed
;
241 pfile
= (PyrFile
*)slotRawObject(a
);
243 memcpy(filename
, slotRawString(b
)->s
, slotRawObject(b
)->size
);
244 filename
[slotRawString(b
)->size
] = 0;
246 memcpy(mode
, slotRawString(c
)->s
, slotRawObject(c
)->size
);
247 mode
[slotRawString(c
)->size
] = 0;
250 win32_ReplaceCharInString(filename
,PATH_MAX
,'/','\\');
251 if(strcmp(mode
,"w") == 0)
253 if(strcmp(mode
,"r") == 0)
257 file
= fopen(filename
, mode
);
259 SetPtr(&pfile
->fileptr
, file
);
263 // check if directory exisits
264 // create a temporary file (somewhere) for a handle
265 // the file is deleted automatically when closed
266 if (sc_DirectoryExists(filename
)) {
269 err
= tmpfile_s(&file
);
271 SetPtr(&pfile
->fileptr
, file
);
275 #elif defined(__MINGW32__)
278 SetPtr(&pfile
->fileptr
, file
);
283 #error compiler unsupported
293 int prFileClose(struct VMGlobals
*g
, int numArgsPushed
)
300 pfile
= (PyrFile
*)slotRawObject(a
);
301 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
302 if (file
== NULL
) return errNone
;
303 SetPtr(&pfile
->fileptr
, NULL
);
304 if (fclose(file
)) return errFailed
;
308 int prFileFlush(struct VMGlobals
*g
, int numArgsPushed
)
315 pfile
= (PyrFile
*)slotRawObject(a
);
316 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
317 if (file
!= NULL
) fflush(file
);
321 int prFilePos(struct VMGlobals
*g
, int numArgsPushed
)
330 pfile
= (PyrFile
*)slotRawObject(a
);
331 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
332 if (file
== NULL
) return errFailed
;
333 if (fgetpos(file
, &pos
)) return errFailed
;
346 int prFileLength(struct VMGlobals
*g
, int numArgsPushed
)
349 PyrFile
*pfile
= (PyrFile
*)slotRawObject(a
);
350 FILE *file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
352 if (file
== NULL
) return errFailed
;
354 // preserve file position
356 if (fgetpos(file
, &pos
)) return errFailed
;
357 if (fseek(file
, 0, SEEK_END
)) return errFailed
;
359 length
= ftell(file
);
360 if (fsetpos(file
, &pos
)) return errFailed
;
366 int prFileSeek(struct VMGlobals
*g
, int numArgsPushed
)
373 static int originTable
[3] = { SEEK_SET
, SEEK_CUR
, SEEK_END
};
378 if (NotInt(b
)) return errWrongType
;
379 if (NotInt(c
)) return errWrongType
;
380 pfile
= (PyrFile
*)slotRawObject(a
);
381 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
382 if (file
== NULL
) return errFailed
;
383 offset
= slotRawInt(b
);
384 origin
= slotRawInt(c
);
385 if (origin
< 0 || origin
> 2) return errIndexOutOfRange
;
386 origin
= originTable
[origin
]; // translate in case ANSI constants ever change..
387 if (fseek(file
, offset
, origin
)) return errFailed
;
392 int prFileWrite(struct VMGlobals
*g
, int numArgsPushed
)
394 PyrSlot
*a
, *b
, *ptr
;
402 pfile
= (PyrFile
*)slotRawObject(a
);
403 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
404 if (file
== NULL
) return errFailed
;
408 SC_IOStream
<FILE*> scio(file
);
409 scio
.writeInt32_be(slotRawInt(b
));
413 fwrite(slotRawSymbol(b
)->name
, sizeof(char), slotRawSymbol(b
)->length
, file
);
416 chr
= slotRawChar(b
);
417 fwrite(&chr
, sizeof(char), 1, file
);
426 // writes the indexable part of any non obj_slot format object
427 obj
= slotRawObject(b
);
428 if (!isKindOf(obj
, class_rawarray
)
429 || isKindOf(obj
, class_symbolarray
)) return errWrongType
;
432 int elemSize
= gFormatElemSize
[obj
->obj_format
];
433 int numElems
= obj
->size
;
434 #if BYTE_ORDER != BIG_ENDIAN
437 fwrite(ptr
, elemSize
, numElems
, file
);
441 char *ptr
= slotRawString(b
)->s
;
442 char *ptrend
= ptr
+ numElems
*2;
443 for (; ptr
< ptrend
; ptr
+=2) {
451 char *ptr
= slotRawString(b
)->s
;
452 char *ptrend
= ptr
+ numElems
*4;
453 for (; ptr
< ptrend
; ptr
+=4) {
463 char *ptr
= slotRawString(b
)->s
;
464 char *ptrend
= ptr
+ numElems
*8;
465 for (; ptr
< ptrend
; ptr
+=8) {
479 fwrite(ptr
, elemSize
, numElems
, file
);
486 SC_IOStream
<FILE*> scio(file
);
487 scio
.writeDouble_be(slotRawFloat(b
));
495 int prFileWriteLE(struct VMGlobals
*g
, int numArgsPushed
)
497 PyrSlot
*a
, *b
, *ptr
;
505 pfile
= (PyrFile
*)slotRawObject(a
);
506 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
507 if (file
== NULL
) return errFailed
;
511 SC_IOStream
<FILE*> scio(file
);
512 scio
.writeInt32_le(slotRawInt(b
));
516 fwrite(slotRawSymbol(b
)->name
, sizeof(char), slotRawSymbol(b
)->length
, file
);
520 fwrite(&chr
, sizeof(char), 1, file
);
529 // writes the indexable part of any non obj_slot format object
530 obj
= slotRawObject(b
);
531 if (!isKindOf(obj
, class_rawarray
)
532 || isKindOf(obj
, class_symbolarray
)) return errWrongType
;
535 int elemSize
= gFormatElemSize
[obj
->obj_format
];
536 int numElems
= obj
->size
;
537 #if BYTE_ORDER == BIG_ENDIAN
540 fwrite(ptr
, elemSize
, numElems
, file
);
544 char *ptr
= slotRawString(b
)->s
;
545 char *ptrend
= ptr
+ numElems
*2;
546 for (; ptr
< ptrend
; ptr
+=2) {
554 char *ptr
= slotRawString(b
)->s
;
555 char *ptrend
= ptr
+ numElems
*4;
556 for (; ptr
< ptrend
; ptr
+=4) {
566 char *ptr
= slotRawString(b
)->s
;
567 char *ptrend
= ptr
+ numElems
*8;
568 for (; ptr
< ptrend
; ptr
+=8) {
582 fwrite(ptr
, elemSize
, numElems
, file
);
589 SC_IOStream
<FILE*> scio(file
);
590 scio
.writeDouble_le(slotRawFloat(b
));
597 int prFileReadLine(struct VMGlobals
*g
, int numArgsPushed
)
599 PyrSlot
*a
, *b
; // receiver(a File), string
606 pfile
= (PyrFile
*)slotRawObject(a
);
607 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
608 if (file
== NULL
) return errFailed
;
610 char* result
= fgets(slotRawString(b
)->s
, MAXINDEXSIZE(slotRawObject(b
)) - 1, file
);
614 slotRawString(b
)->size
= strlen(slotRawString(b
)->s
);
615 if (slotRawString(b
)->s
[slotRawString(b
)->size
-1] == '\n') slotRawString(b
)->size
--;
621 int prFilePutInt32(struct VMGlobals
*g
, int numArgsPushed
)
630 pfile
= (PyrFile
*)slotRawObject(a
);
631 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
632 if (file
== NULL
) return errFailed
;
635 int err
= slotIntVal(b
, &val
);
638 SC_IOStream
<FILE*> scio(file
);
639 scio
.writeInt32_be(val
);
644 int prFilePutInt16(struct VMGlobals
*g
, int numArgsPushed
)
653 pfile
= (PyrFile
*)slotRawObject(a
);
654 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
655 if (file
== NULL
) return errFailed
;
658 int err
= slotIntVal(b
, &val
);
662 SC_IOStream
<FILE*> scio(file
);
663 scio
.writeInt16_be(val
);
669 int prFilePutInt32LE(struct VMGlobals
*g
, int numArgsPushed
)
678 pfile
= (PyrFile
*)slotRawObject(a
);
679 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
680 if (file
== NULL
) return errFailed
;
683 int err
= slotIntVal(b
, &val
);
686 SC_IOStream
<FILE*> scio(file
);
687 scio
.writeInt32_le(val
);
692 int prFilePutInt16LE(struct VMGlobals
*g
, int numArgsPushed
)
701 pfile
= (PyrFile
*)slotRawObject(a
);
702 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
703 if (file
== NULL
) return errFailed
;
706 int err
= slotIntVal(b
, &val
);
710 SC_IOStream
<FILE*> scio(file
);
711 scio
.writeInt16_le(val
);
716 int prFilePutInt8(struct VMGlobals
*g
, int numArgsPushed
)
725 pfile
= (PyrFile
*)slotRawObject(a
);
726 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
727 if (file
== NULL
) return errFailed
;
730 int err
= slotIntVal(b
, &val
);
734 SC_IOStream
<FILE*> scio(file
);
740 int prFilePutChar(struct VMGlobals
*g
, int numArgsPushed
)
750 pfile
= (PyrFile
*)slotRawObject(a
);
751 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
752 if (file
== NULL
) return errFailed
;
753 if (NotChar(b
)) return errWrongType
;
757 SC_IOStream
<FILE*> scio(file
);
763 int prFilePutFloat(struct VMGlobals
*g
, int numArgsPushed
)
772 pfile
= (PyrFile
*)slotRawObject(a
);
773 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
780 int err
= slotFloatVal(b
, &val
);
783 SC_IOStream
<FILE*> scio(file
);
784 scio
.writeFloat_be(val
);
789 int prFilePutDouble(struct VMGlobals
*g
, int numArgsPushed
)
798 pfile
= (PyrFile
*)slotRawObject(a
);
799 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
800 if (file
== NULL
) return errFailed
;
804 int err
= slotDoubleVal(b
, &val
);
807 SC_IOStream
<FILE*> scio(file
);
808 scio
.writeDouble_be(val
);
814 int prFilePutFloatLE(struct VMGlobals
*g
, int numArgsPushed
)
823 pfile
= (PyrFile
*)slotRawObject(a
);
824 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
831 int err
= slotFloatVal(b
, &val
);
834 SC_IOStream
<FILE*> scio(file
);
835 scio
.writeFloat_le(val
);
840 int prFilePutDoubleLE(struct VMGlobals
*g
, int numArgsPushed
)
849 pfile
= (PyrFile
*)slotRawObject(a
);
850 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
851 if (file
== NULL
) return errFailed
;
855 int err
= slotDoubleVal(b
, &val
);
858 SC_IOStream
<FILE*> scio(file
);
859 scio
.writeDouble_le(val
);
864 int prFilePutString(struct VMGlobals
*g
, int numArgsPushed
)
873 pfile
= (PyrFile
*)slotRawObject(a
);
874 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
875 if (file
== NULL
) return errFailed
;
876 if (NotObj(b
) || slotRawObject(b
)->classptr
!= class_string
) return errWrongType
;
877 string
= slotRawString(b
);
879 fwrite(string
->s
, 1, string
->size
, file
);
885 int prFileGetDouble(struct VMGlobals
*g
, int numArgsPushed
)
893 pfile
= (PyrFile
*)slotRawObject(a
);
894 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
895 if (file
== NULL
) return errFailed
;
897 if (feof(file
)) SetNil(a
);
899 SC_IOStream
<FILE*> scio(file
);
900 SetFloat(a
, scio
.readDouble_be());
905 int prFileGetFloat(struct VMGlobals
*g
, int numArgsPushed
)
913 pfile
= (PyrFile
*)slotRawObject(a
);
914 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
915 if (file
== NULL
) return errFailed
;
917 if (feof(file
)) SetNil(a
);
919 SC_IOStream
<FILE*> scio(file
);
920 SetFloat(a
, scio
.readFloat_be());
926 int prFileGetDoubleLE(struct VMGlobals
*g
, int numArgsPushed
)
934 pfile
= (PyrFile
*)slotRawObject(a
);
935 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
936 if (file
== NULL
) return errFailed
;
938 if (feof(file
)) SetNil(a
);
940 SC_IOStream
<FILE*> scio(file
);
941 SetFloat(a
, scio
.readDouble_le());
946 int prFileGetFloatLE(struct VMGlobals
*g
, int numArgsPushed
)
954 pfile
= (PyrFile
*)slotRawObject(a
);
955 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
956 if (file
== NULL
) return errFailed
;
958 if (feof(file
)) SetNil(a
);
960 SC_IOStream
<FILE*> scio(file
);
961 SetFloat(a
, scio
.readFloat_le());
966 int prFileGetChar(struct VMGlobals
*g
, int numArgsPushed
)
975 pfile
= (PyrFile
*)slotRawObject(a
);
976 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
977 if (file
== NULL
) return errFailed
;
979 int count
= fread(&z
, sizeof(char), 1, file
);
980 if (count
==0) SetNil(a
);
985 int prFileGetInt8(struct VMGlobals
*g
, int numArgsPushed
)
994 pfile
= (PyrFile
*)slotRawObject(a
);
995 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
996 if (file
== NULL
) return errFailed
;
998 int count
= fread(&z
, sizeof(int8
), 1, file
);
999 if (count
==0) SetNil(a
);
1004 int prFileGetInt16(struct VMGlobals
*g
, int numArgsPushed
)
1012 pfile
= (PyrFile
*)slotRawObject(a
);
1013 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
1014 if (file
== NULL
) return errFailed
;
1016 if (feof(file
)) SetNil(a
);
1018 SC_IOStream
<FILE*> scio(file
);
1019 SetInt(a
, scio
.readInt16_be());
1024 int prFileGetInt32(struct VMGlobals
*g
, int numArgsPushed
)
1032 pfile
= (PyrFile
*)slotRawObject(a
);
1033 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
1037 if (feof(file
)) SetNil(a
);
1039 SC_IOStream
<FILE*> scio(file
);
1040 SetInt(a
, scio
.readInt32_be());
1046 int prFileGetInt16LE(struct VMGlobals
*g
, int numArgsPushed
)
1054 pfile
= (PyrFile
*)slotRawObject(a
);
1055 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
1056 if (file
== NULL
) return errFailed
;
1058 if (feof(file
)) SetNil(a
);
1060 SC_IOStream
<FILE*> scio(file
);
1061 SetInt(a
, scio
.readInt16_le());
1066 int prFileGetInt32LE(struct VMGlobals
*g
, int numArgsPushed
)
1074 pfile
= (PyrFile
*)slotRawObject(a
);
1075 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
1076 if (file
== NULL
) return errFailed
;
1078 if (feof(file
)) SetNil(a
);
1080 SC_IOStream
<FILE*> scio(file
);
1081 SetInt(a
, scio
.readInt32_le());
1086 int prFileReadRaw(struct VMGlobals
*g
, int numArgsPushed
)
1091 PyrSlot
* a
= g
->sp
- 1;
1094 if (!isKindOfSlot(b
, class_rawarray
)
1095 || isKindOfSlot(b
, class_symbolarray
)) return errWrongType
;
1097 pfile
= (PyrFile
*)slotRawObject(a
);
1098 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
1099 if (file
== NULL
) return errFailed
;
1101 int elemSize
= gFormatElemSize
[slotRawObject(b
)->obj_format
];
1102 int numElems
= slotRawObject(b
)->size
;
1103 numElems
= fread(slotRawString(b
)->s
, elemSize
, numElems
, file
);
1104 slotRawObject(b
)->size
= numElems
;
1106 #if BYTE_ORDER != BIG_ENDIAN
1112 char *ptr
= slotRawString(b
)->s
;
1113 char *ptrend
= ptr
+ numElems
*2;
1114 for (; ptr
< ptrend
; ptr
+=2) {
1123 char *ptr
= slotRawString(b
)->s
;
1124 char *ptrend
= ptr
+ numElems
*4;
1125 for (; ptr
< ptrend
; ptr
+=4) {
1138 char *ptr
= slotRawString(b
)->s
;
1139 char *ptrend
= ptr
+ numElems
*8;
1140 for (; ptr
< ptrend
; ptr
+=8) {
1162 if (slotRawObject(b
)->size
==0) SetNil(a
);
1167 int prFileReadRawLE(struct VMGlobals
*g
, int numArgsPushed
)
1172 PyrSlot
* a
= g
->sp
- 1;
1175 if (!isKindOfSlot(b
, class_rawarray
)
1176 || isKindOfSlot(b
, class_symbolarray
)) return errWrongType
;
1178 pfile
= (PyrFile
*)slotRawObject(a
);
1179 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
1180 if (file
== NULL
) return errFailed
;
1182 int elemSize
= gFormatElemSize
[slotRawObject(b
)->obj_format
];
1183 int numElems
= slotRawObject(b
)->size
;
1184 numElems
= fread(slotRawString(b
)->s
, elemSize
, numElems
, file
);
1185 slotRawObject(b
)->size
= numElems
;
1187 #if BYTE_ORDER == BIG_ENDIAN
1193 char *ptr
= slotRawString(b
)->s
;
1194 char *ptrend
= ptr
+ numElems
*2;
1195 for (; ptr
< ptrend
; ptr
+=2) {
1204 char *ptr
= slotRawString(b
)->s
;
1205 char *ptrend
= ptr
+ numElems
*4;
1206 for (; ptr
< ptrend
; ptr
+=4) {
1219 char *ptr
= slotRawString(b
)->s
;
1220 char *ptrend
= ptr
+ numElems
*8;
1221 for (; ptr
< ptrend
; ptr
+=8) {
1243 if (slotRawObject(b
)->size
==0) SetNil(a
);
1248 int prFileGetcwd(struct VMGlobals
*g
, int numArgsPushed
)
1250 //PyrSlot* a = g->sp - 1; // File
1251 PyrSlot
* string
= g
->sp
;
1253 if (!isKindOfSlot(string
, class_string
)) return errWrongType
;
1255 char * cwd
= getcwd(slotRawString(string
)->s
,255);
1257 error(strerror(errno
));
1260 slotRawString(string
)->size
= strlen(slotRawString(string
)->s
);
1267 int prPipeOpen(struct VMGlobals
*g
, int numArgsPushed
)
1278 if (NotObj(c
) || !isKindOf(slotRawObject(c
), class_string
)
1279 || NotObj(b
) || !isKindOf(slotRawObject(b
), class_string
))
1280 return errWrongType
;
1281 if (slotRawObject(c
)->size
> 11) return errFailed
;
1282 pfile
= (PyrFile
*)slotRawObject(a
);
1284 char *commandLine
= (char*)malloc(slotRawObject(b
)->size
+ 1);
1285 memcpy(commandLine
, slotRawString(b
)->s
, slotRawObject(b
)->size
);
1286 commandLine
[slotRawString(b
)->size
] = 0;
1288 memcpy(mode
, slotRawString(c
)->s
, slotRawObject(c
)->size
);
1289 mode
[slotRawString(c
)->size
] = 0;
1292 file
= sc_popen(commandLine
, &pid
, mode
);
1295 SetPtr(&pfile
->fileptr
, file
);
1303 int prPipeClose(struct VMGlobals
*g
, int numArgsPushed
)
1313 pfile
= (PyrFile
*)slotRawObject(a
);
1314 file
= (FILE*)slotRawPtr(&pfile
->fileptr
);
1315 if (file
== NULL
) return errNone
;
1316 pid
= (pid_t
) slotRawInt(b
);
1318 SetPtr(&pfile
->fileptr
, NULL
);
1319 int perr
= sc_pclose(file
, pid
);
1328 #ifndef NO_LIBSNDFILE
1331 #include <sndfile-win.h>
1333 #include <sndfile.h>
1337 int sampleFormatToString(struct SF_INFO
*info
, const char **string
);
1338 int sampleFormatToString(struct SF_INFO
*info
, const char **string
)
1340 unsigned int format
= info
->format
& SF_FORMAT_SUBMASK
;
1343 case SF_FORMAT_DPCM_8
:
1344 case SF_FORMAT_PCM_S8
:
1347 case SF_FORMAT_DPCM_16
:
1348 case SF_FORMAT_PCM_16
:
1349 case SF_FORMAT_DWVW_16
:
1352 case SF_FORMAT_PCM_24
:
1353 case SF_FORMAT_DWVW_24
:
1356 case SF_FORMAT_PCM_32
:
1359 case SF_FORMAT_FLOAT
:
1362 case SF_FORMAT_DOUBLE
:
1365 case SF_FORMAT_ULAW
:
1368 case SF_FORMAT_ALAW
:
1379 int headerFormatToString(struct SF_INFO
*info
, const char **string
);
1380 int headerFormatToString(struct SF_INFO
*info
, const char **string
){
1381 switch (info
->format
& SF_FORMAT_TYPEMASK
)
1383 case SF_FORMAT_WAV
:
1386 case SF_FORMAT_AIFF
:
1392 case SF_FORMAT_IRCAM
:
1395 case SF_FORMAT_RAW
:
1398 case SF_FORMAT_W64
:
1401 case SF_FORMAT_FLAC
:
1404 // TODO allow other platforms to know vorbis once libsndfile 1.0.18 is established
1405 #if SC_DARWIN || SC_WIN32 || LIBSNDFILE_1018
1406 case SF_FORMAT_VORBIS
:
1411 case SF_FORMAT_PAF :
1415 case SF_FORMAT_SVX :
1419 case SF_FORMAT_NIST :
1423 case SF_FORMAT_VOC :
1427 case SF_FORMAT_MAT4 :
1431 case SF_FORMAT_MAT5 :
1435 case SF_FORMAT_PVF :
1443 case SF_FORMAT_HTK :
1447 case SF_FORMAT_SDS :
1458 int sndfileFormatInfoToStrings(struct SF_INFO
*info
, const char **stringHead
, const char **stringSample
);
1459 int sndfileFormatInfoToStrings(struct SF_INFO
*info
, const char **stringHead
, const char **stringSample
)
1462 error
= headerFormatToString(info
, stringHead
);
1463 error
= sampleFormatToString(info
, stringSample
);
1467 int prSFOpenRead(struct VMGlobals
*g
, int numArgsPushed
);
1468 int prSFOpenRead(struct VMGlobals
*g
, int numArgsPushed
)
1471 char filename
[PATH_MAX
];
1474 const char *headerstr
;
1475 const char *sampleformatstr
;
1480 if (!isKindOfSlot(b
, class_string
)) return errWrongType
;
1481 if (slotRawObject(b
)->size
> PATH_MAX
- 1) return errFailed
;
1483 memcpy(filename
, slotRawString(b
)->s
, slotRawObject(b
)->size
);
1484 filename
[slotRawString(b
)->size
] = 0;
1487 file
= sf_open(filename
, SFM_READ
, &info
);
1491 SetPtr(slotRawObject(a
)->slots
+ 0, file
);
1492 sndfileFormatInfoToStrings(&info
, &headerstr
, &sampleformatstr
);
1493 //headerFormatToString(&info, &headerstr);
1494 PyrString
*hpstr
= newPyrString(g
->gc
, headerstr
, 0, true);
1495 SetObject(slotRawObject(a
)->slots
+1, hpstr
);
1496 PyrString
*smpstr
= newPyrString(g
->gc
, sampleformatstr
, 0, true);
1497 SetObject(slotRawObject(a
)->slots
+2, smpstr
);
1498 SetInt(slotRawObject(a
)->slots
+ 3, info
.frames
);
1499 SetInt(slotRawObject(a
)->slots
+ 4, info
.channels
);
1500 SetInt(slotRawObject(a
)->slots
+ 5, info
.samplerate
);
1510 int prSFOpenWrite(struct VMGlobals
*g
, int numArgsPushed
);
1511 int prSFOpenWrite(struct VMGlobals
*g
, int numArgsPushed
)
1514 char filename
[PATH_MAX
];
1517 PyrSlot
*headerSlot
;
1518 PyrSlot
*formatSlot
;
1525 headerSlot
= (slotRawObject(a
)->slots
+ 1);
1526 formatSlot
= (slotRawObject(a
)->slots
+ 2);
1529 if (!isKindOfSlot(headerSlot
, class_string
)) return errWrongType
;
1530 if (!isKindOfSlot(formatSlot
, class_string
)) return errWrongType
;
1532 if (!isKindOfSlot(b
, class_string
)) return errWrongType
;
1533 if (slotRawObject(b
)->size
> PATH_MAX
- 1) return errFailed
;
1535 memcpy(filename
, slotRawString(b
)->s
, slotRawObject(b
)->size
);
1536 filename
[slotRawString(b
)->size
] = 0;
1539 char* headerFormat
= (char *)malloc(slotRawObject(headerSlot
)->size
);
1541 char headerFormat
[slotRawString(headerSlot
)->size
];
1543 memcpy(headerFormat
, slotRawString(headerSlot
)->s
, slotRawObject(headerSlot
)->size
);
1544 headerFormat
[slotRawString(headerSlot
)->size
] = 0;
1547 char* sampleFormat
= (char *)malloc(slotRawString(formatSlot
)->size
);
1549 char sampleFormat
[slotRawString(formatSlot
)->size
];
1551 memcpy(sampleFormat
, slotRawString(formatSlot
)->s
, slotRawObject(formatSlot
)->size
);
1552 sampleFormat
[slotRawString(formatSlot
)->size
] = 0;
1554 error
= sndfileFormatInfoFromStrings(&info
, headerFormat
, sampleFormat
);
1563 if(error
) return errFailed
;
1564 //slotIntVal(slotRawObject(a)->slots + 3, &info.frames);
1565 slotIntVal(slotRawObject(a
)->slots
+ 4, &info
.channels
);
1566 slotIntVal(slotRawObject(a
)->slots
+ 5, &info
.samplerate
);
1568 file
= sf_open(filename
, SFM_WRITE
, &info
);
1569 sf_command(file
, SFC_SET_CLIPPING
, NULL
, SF_TRUE
);
1572 SetPtr(slotRawObject(a
)->slots
+0, file
);
1582 int prSFClose(struct VMGlobals
*g
, int numArgsPushed
);
1583 int prSFClose(struct VMGlobals
*g
, int numArgsPushed
)
1589 SNDFILE
*file
= (SNDFILE
*)slotRawPtr(&slotRawObject(a
)->slots
[0]);
1592 SetNil(slotRawObject(a
)->slots
+ 0);
1598 int prSFRead(struct VMGlobals
*g
, int numArgsPushed
);
1599 int prSFRead(struct VMGlobals
*g
, int numArgsPushed
)
1606 SNDFILE
*file
= (SNDFILE
*)slotRawPtr(&slotRawObject(a
)->slots
[0]);
1608 if (!isKindOfSlot(b
, class_rawarray
)) return errWrongType
;
1610 switch (slotRawObject(b
)->obj_format
) {
1612 slotRawObject(b
)->size
= sf_read_short(file
, (short*)slotRawInt8Array(b
)->b
, slotRawObject(b
)->size
);
1615 slotRawObject(b
)->size
= sf_read_int(file
, (int*)slotRawInt8Array(b
)->b
, slotRawObject(b
)->size
);
1618 slotRawObject(b
)->size
= sf_read_float(file
, (float*)slotRawInt8Array(b
)->b
, slotRawObject(b
)->size
);
1621 slotRawObject(b
)->size
= sf_read_double(file
, (double*)slotRawInt8Array(b
)->b
, slotRawObject(b
)->size
);
1624 error("sample format not supported.\n");
1631 int prSFWrite(struct VMGlobals
*g
, int numArgsPushed
);
1632 int prSFWrite(struct VMGlobals
*g
, int numArgsPushed
)
1639 SNDFILE
*file
= (SNDFILE
*)slotRawPtr(&slotRawObject(a
)->slots
[0]);
1641 if (!isKindOfSlot(b
, class_rawarray
)) return errWrongType
;
1643 switch (slotRawObject(b
)->obj_format
) {
1645 sf_write_short(file
, (short*)slotRawInt8Array(b
)->b
, slotRawObject(b
)->size
);
1648 sf_write_int(file
, (int*)slotRawInt8Array(b
)->b
, slotRawObject(b
)->size
);
1651 sf_write_float(file
, (float*)slotRawInt8Array(b
)->b
, slotRawObject(b
)->size
);
1654 sf_write_double(file
, (double*)slotRawInt8Array(b
)->b
, slotRawObject(b
)->size
);
1657 error("sample format not supported.\n");
1664 int prSFSeek(struct VMGlobals
*g
, int numArgsPushed
);
1665 int prSFSeek(struct VMGlobals
*g
, int numArgsPushed
)
1673 SNDFILE
*file
= (SNDFILE
*)slotRawPtr(&slotRawObject(a
)->slots
[0]);
1676 int err
= slotIntVal(b
, &offset
);
1677 if (err
) return err
;
1679 err
= slotIntVal(c
, &origin
);
1680 if (err
) return err
;
1682 sf_seek(file
, offset
, origin
);
1687 int prSFHeaderInfoString(struct VMGlobals
*g
, int numArgsPushed
);
1688 int prSFHeaderInfoString(struct VMGlobals
*g
, int numArgsPushed
)
1693 SNDFILE
*file
= (SNDFILE
*)slotRawPtr(&slotRawObject(a
)->slots
[0]);
1695 static char strbuffer
[(1 << 16)] ;
1696 sf_command (file
, SFC_GET_LOG_INFO
, strbuffer
, (1 << 16)) ;
1697 PyrString
*pstring
= newPyrString(g
->gc
, strbuffer
, 0, true);
1699 SetObject(a
, pstring
);
1705 #else // !NO_LIBSNDFILE
1707 int prSFOpenRead(struct VMGlobals
*g
, int numArgsPushed
)
1712 int prSFOpenWrite(struct VMGlobals
*g
, int numArgsPushed
)
1717 int prSFClose(struct VMGlobals
*g
, int numArgsPushed
)
1722 int prSFWrite(struct VMGlobals
*g
, int numArgsPushed
)
1727 int prSFRead(struct VMGlobals
*g
, int numArgsPushed
)
1732 int prSFSeek(struct VMGlobals
*g
, int numArgsPushed
)
1737 int prSFHeaderInfoString(struct VMGlobals
*g
, int numArgsPushed
)
1742 #endif // !NO_LIBSNDFILE
1748 int dir_Lookup(char *pathString
, int pathStringLength
, int index
,
1750 char *name
, int *nameLength
, int *creationDate
, int *modificationDate
,
1751 int *isDirectory
, int *isVisible
, int *sizeIfFile
);
1753 int prDirectory_At(struct VMGlobals
*g
, int numArgsPushed
);
1754 int prDirectory_At(struct VMGlobals
*g
, int numArgsPushed
)
1756 PyrSlot
*a
= g
->sp
- 2;
1757 PyrSlot
*b
= g
->sp
- 1;
1760 PyrSlot
*dirPathSlot
= slotRawObject(a
)->slots
+ 0;
1762 err
= slotIntVal(c
, &index
);
1768 char name
[256], fullPathName
[256];
1769 int nameLength
, creationDate
, modificationDate
, isDirectory
, isVisible
, sizeIfFile
;
1770 int dirPathLength
= slotRawObject(dirPathSlot
)->size
;
1772 err
= dir_Lookup(slotRawObject(dirPathSlot
)s
->s
, dirPathLength
, index
+1,
1773 name
, &nameLength
, &creationDate
, &modificationDate
, &isDirectory
, &isVisible
, &sizeIfFile
);
1779 error("Invalid path\n");
1784 if (dirPathLength
+ nameLength
+ 1 > 255) {
1785 error("Full path name too long.\n");
1790 PyrSlot
*entryName
= slotRawObject(b
)->slots
+ 0;
1791 PyrSlot
*entryPath
= slotRawObject(b
)->slots
+ 1;
1792 PyrSlot
*entryIsDir
= slotRawObject(b
)->slots
+ 2;
1793 PyrSlot
*entryIsVisible
= slotRawObject(b
)->slots
+ 3;
1795 PyrString
*nameString
= newPyrString(g
->gc
, name
, 0, true);
1796 SetObject(entryName
, nameString
);
1797 g
->gc
->GCWrite(slotRawObject(b
), (PyrObject
*)nameString
);
1799 memcpy(fullPathName
, slotRawObject(dirPathSlot
)s
->s
, dirPathLength
);
1800 fullPathName
[dirPathLength
] = DELIMITOR
;
1801 strcpy(fullPathName
+ dirPathLength
+ 1, name
);
1803 PyrString
*pathString
= newPyrString(g
->gc
, fullPathName
, 0, true);
1804 SetObject(entryPath
, pathString
);
1805 g
->gc
->GCWrite(slotRawObject(b
), (PyrObject
*)pathString
);
1807 if (isDirectory
) { SetTrue(entryIsDir
); } else { SetFalse(entryIsDir
); }
1808 if (isVisible
) { SetTrue(entryIsVisible
); } else { SetFalse(entryIsVisible
); }
1815 Boolean
GetFullPathname(const FSSpec
* aSpec
, Str255 pathname
);
1816 void pstrncpy(unsigned char *s1
, unsigned char *s2
, int n
);
1818 int prFile_GetFile(struct VMGlobals
*g
, int numArgsPushed
);
1819 int prFile_GetFile(struct VMGlobals
*g
, int numArgsPushed
)
1822 PyrSlot
*a
= g
->sp
- 1;
1825 NavDialogOptions options
;
1827 int err
= NavGetDefaultDialogOptions(&options
);
1828 if (err
) return errFailed
;
1830 options
.dialogOptionFlags
|= kNavNoTypePopup
;
1831 options
.dialogOptionFlags
|= kNavDontAutoTranslate
;
1832 options
.dialogOptionFlags
|= kNavDontAddTranslateItems
;
1833 options
.dialogOptionFlags
|= kNavSelectDefaultLocation
;
1834 options
.dialogOptionFlags
&= ~kNavAllowPreviews
;
1835 options
.dialogOptionFlags
&= ~kNavAllowMultipleFiles
;
1837 if (isKindOfSlot(b
, class_string
)) {
1838 pstringFromPyrString((PyrString
*)slotRawObject(b
), options
.message
, 256);
1841 NavReplyRecord reply
;
1842 err
= NavGetFile(0, &reply
, &options
, 0, 0, 0, 0, 0);
1844 if (err
== noErr
&& reply
.validRecord
) {
1846 DescType actualType
;
1850 err
= AEGetNthPtr(&reply
.selection
, 1, typeFSS
, &keyword
, &actualType
,
1851 &fsspec
, sizeof(FSSpec
), &actualSize
);
1855 GetFullPathname(&fsspec
, pathname
);
1857 PyrString
*string
= newPyrString(g
->gc
, (char*)pathname
, 0, true);
1858 SetObject(a
, string
);
1862 err
= NavDisposeReply(&reply
);
1871 int prFile_PutFile(struct VMGlobals
*g
, int numArgsPushed
);
1872 int prFile_PutFile(struct VMGlobals
*g
, int numArgsPushed
)
1875 PyrSlot
*a
= g
->sp
- 2;
1876 PyrSlot
*b
= g
->sp
- 1;
1879 NavDialogOptions options
;
1881 int err
= NavGetDefaultDialogOptions(&options
);
1882 if (err
) return errFailed
;
1884 options
.dialogOptionFlags
|= kNavNoTypePopup
;
1885 options
.dialogOptionFlags
|= kNavDontAutoTranslate
;
1886 options
.dialogOptionFlags
|= kNavDontAddTranslateItems
;
1887 options
.dialogOptionFlags
|= kNavSelectDefaultLocation
;
1888 options
.dialogOptionFlags
&= ~kNavAllowPreviews
;
1889 options
.dialogOptionFlags
&= ~kNavAllowMultipleFiles
;
1891 if (isKindOfSlot(b
, class_string
)) {
1892 pstringFromPyrString((PyrString
*)slotRawObject(b
), options
.message
, 256);
1895 if (isKindOfSlot(c
, class_string
)) {
1896 pstringFromPyrString((PyrString
*)slotRawObject(c
), options
.savedFileName
, 256);
1898 //pstrncpy(options.savedFileName, "\pUntitled", 255);
1901 NavReplyRecord reply
;
1902 err
= NavPutFile(0, &reply
, &options
, 0, 'TEXT', 'SCjm', 0);
1904 if (err
== noErr
&& reply
.validRecord
) {
1906 DescType actualType
;
1910 err
= AEGetNthPtr(&reply
.selection
, 1, typeFSS
, &keyword
, &actualType
,
1911 &fsspec
, sizeof(FSSpec
), &actualSize
);
1915 GetFullPathname(&fsspec
, pathname
);
1917 PyrString
*string
= newPyrString(g
->gc
, (char*)pathname
, 0, true);
1918 SetObject(a
, string
);
1920 err
= NavCompleteSave(&reply
, kNavTranslateInPlace
);
1924 err
= NavDisposeReply(&reply
);
1935 void initFilePrimitives()
1939 base
= nextPrimitiveIndex();
1942 definePrimitive(base
, index
++, "_SFOpenRead", prSFOpenRead
, 2, 0);
1943 definePrimitive(base
, index
++, "_SFOpenWrite", prSFOpenWrite
, 2, 0);
1944 definePrimitive(base
, index
++, "_SFClose", prSFClose
, 1, 0);
1945 definePrimitive(base
, index
++, "_SFWrite", prSFWrite
, 2, 0);
1946 definePrimitive(base
, index
++, "_SFRead", prSFRead
, 2, 0);
1947 definePrimitive(base
, index
++, "_SFSeek", prSFSeek
, 3, 0);
1948 definePrimitive(base
, index
++, "_SFHeaderInfoString", prSFHeaderInfoString
, 1, 0);
1950 definePrimitive(base
, index
++, "_PipeOpen", prPipeOpen
, 3, 0);
1951 definePrimitive(base
, index
++, "_PipeClose", prPipeClose
, 2, 0);
1953 definePrimitive(base
, index
++, "_FileDelete", prFileDelete
, 2, 0);
1954 definePrimitive(base
, index
++, "_FileMTime", prFileMTime
, 2, 0);
1955 definePrimitive(base
, index
++, "_FileExists", prFileExists
, 2, 0);
1956 definePrimitive(base
, index
++, "_FileRealPath", prFileRealPath
, 2, 0);
1957 definePrimitive(base
, index
++, "_FileMkDir", prFileMkDir
, 2, 0);
1958 definePrimitive(base
, index
++, "_FileCopy", prFileCopy
, 3, 0);
1959 definePrimitive(base
, index
++, "_FileType", prFileType
, 2, 0);
1960 definePrimitive(base
, index
++, "_FileSize", prFileSize
, 2, 0);
1962 definePrimitive(base
, index
++, "_FileOpen", prFileOpen
, 3, 0);
1963 definePrimitive(base
, index
++, "_FileClose", prFileClose
, 1, 0);
1964 definePrimitive(base
, index
++, "_FileFlush", prFileFlush
, 1, 0);
1965 definePrimitive(base
, index
++, "_FileSeek", prFileSeek
, 3, 0);
1966 definePrimitive(base
, index
++, "_FilePos", prFilePos
, 1, 0);
1967 definePrimitive(base
, index
++, "_FileLength", prFileLength
, 1, 0);
1968 definePrimitive(base
, index
++, "_FileWrite", prFileWrite
, 2, 0);
1969 definePrimitive(base
, index
++, "_FileWriteLE", prFileWriteLE
, 2, 0);
1970 definePrimitive(base
, index
++, "_FileReadLine", prFileReadLine
, 2, 0);
1971 definePrimitive(base
, index
++, "_File_getcwd", prFileGetcwd
, 2, 0);
1973 definePrimitive(base
, index
++, "_FilePutChar", prFilePutChar
, 2, 0);
1974 definePrimitive(base
, index
++, "_FilePutInt8", prFilePutInt8
, 2, 0);
1975 definePrimitive(base
, index
++, "_FilePutInt16", prFilePutInt16
, 2, 0);
1976 definePrimitive(base
, index
++, "_FilePutInt32", prFilePutInt32
, 2, 0);
1977 definePrimitive(base
, index
++, "_FilePutFloat", prFilePutFloat
, 2, 0);
1978 definePrimitive(base
, index
++, "_FilePutDouble", prFilePutDouble
, 2, 0);
1979 definePrimitive(base
, index
++, "_FilePutInt16LE", prFilePutInt16LE
, 2, 0);
1980 definePrimitive(base
, index
++, "_FilePutInt32LE", prFilePutInt32LE
, 2, 0);
1981 definePrimitive(base
, index
++, "_FilePutFloatLE", prFilePutFloatLE
, 2, 0);
1982 definePrimitive(base
, index
++, "_FilePutDoubleLE", prFilePutDoubleLE
, 2, 0);
1984 definePrimitive(base
, index
++, "_FileGetChar", prFileGetChar
, 1, 0);
1985 definePrimitive(base
, index
++, "_FileGetInt8", prFileGetInt8
, 1, 0);
1986 definePrimitive(base
, index
++, "_FileGetInt16", prFileGetInt16
, 1, 0);
1987 definePrimitive(base
, index
++, "_FileGetInt32", prFileGetInt32
, 1, 0);
1988 definePrimitive(base
, index
++, "_FileGetFloat", prFileGetFloat
, 1, 0);
1989 definePrimitive(base
, index
++, "_FileGetDouble", prFileGetDouble
, 1, 0);
1990 definePrimitive(base
, index
++, "_FileGetInt16LE", prFileGetInt16LE
, 1, 0);
1991 definePrimitive(base
, index
++, "_FileGetInt32LE", prFileGetInt32LE
, 1, 0);
1992 definePrimitive(base
, index
++, "_FileGetFloatLE", prFileGetFloatLE
, 1, 0);
1993 definePrimitive(base
, index
++, "_FileGetDoubleLE", prFileGetDoubleLE
, 1, 0);
1995 definePrimitive(base
, index
++, "_FilePutString", prFilePutString
, 2, 0);
1997 definePrimitive(base
, index
++, "_FileReadRaw", prFileReadRaw
, 2, 0);
1998 definePrimitive(base
, index
++, "_FileReadRawLE", prFileReadRawLE
, 2, 0);
2001 definePrimitive(base
, index
++, "_Directory_At", prDirectory_At
, 3, 0);
2002 definePrimitive(base
, index
++, "_File_GetFile", prFile_GetFile
, 2, 0);
2003 definePrimitive(base
, index
++, "_File_PutFile", prFile_PutFile
, 3, 0);