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