This commit was manufactured by cvs2svn to create tag 'buildscript'.
[IRC.git] /
1 #include <fcntl.h>
2 #include <sys/types.h>
3 #include <sys/stat.h>
4 //#ifndef RAW
5 //#include <sys/uio.h>
6 //#endif
7 #include <unistd.h>
8 #include "structdefs.h"
9 #include "mem.h"
10 #include "runtime.h"
11
12 void CALL34(___FileOutputStream______nativeWrite____I__AR_B_I_I, int fd, int off, int len, int fd, struct ArrayObject * ___array___, int off, int len) {
13   char * string= (((char *)&VAR(___array___)->___length___)+sizeof(int));
14   int status=write(fd, &string[off], len);
15 }
16
17 void CALL11(___FileOutputStream______nativeClose____I, int fd, int fd) {
18   close(fd);
19 }
20
21 void CALL11(___FileOutputStream______nativeFlush____I, int fd, int fd) {
22   // not supported in RAW version
23 #ifndef RAW
24   fsync(fd);
25 #endif
26 }
27
28 int CALL01(___FileOutputStream______nativeOpen_____AR_B, struct ArrayObject * ___filename___) {
29   int length=VAR(___filename___)->___length___;
30   char* filename= (((char *)&VAR(___filename___)->___length___)+sizeof(int));
31   int fd=open(filename, O_WRONLY|O_CREAT|O_TRUNC, S_IRWXU);
32   return fd;
33 }
34
35 int CALL01(___FileOutputStream______nativeAppend_____AR_B, struct ArrayObject * ___filename___) {
36   int length=VAR(___filename___)->___length___;
37   char* filename= (((char *)&VAR(___filename___)->___length___)+sizeof(int));
38   int fd=open(filename, O_WRONLY|O_CREAT|O_APPEND, S_IRWXU);
39   return fd;
40 }
41
42 int CALL01(___FileInputStream______nativeOpen_____AR_B, struct ArrayObject * ___filename___) {
43   int length=VAR(___filename___)->___length___;
44   char* filename= (((char *)&VAR(___filename___)->___length___)+sizeof(int));
45   int fd=open(filename, O_RDONLY, 0);
46   return fd;
47 }
48
49 void CALL11(___FileInputStream______nativeClose____I, int fd, int fd) {
50   close(fd);
51 }
52
53 int CALL23(___FileInputStream______nativeRead____I__AR_B_I, int fd, int numBytes, int fd, struct ArrayObject * ___array___, int numBytes) {
54   int toread=VAR(___array___)->___length___;
55   char* string= (((char *)&VAR(___array___)->___length___)+sizeof(int));
56   int status;
57
58   if (numBytes<toread)
59     toread=numBytes;
60
61   status=read(fd, string, toread);
62   return status;
63 }
64
65 long long CALL01(___File______nativeLength_____AR_B, struct ArrayObject * ___pathname___) {
66   int length=VAR(___pathname___)->___length___;
67   char* filename= (((char *)&VAR(___pathname___)->___length___)+sizeof(int));
68   struct stat st;
69   stat(filename, &st);
70   return st.st_size;
71 }