History

My first initial commit with all of mine experimental changes.

Dmitry Kabak (userdima committed 13 years ago

Commit d37b88d1 parent 3f5b46618352 files · +2598093 −-8690Browse files

Showing the changes to java/pkg2/java/io/FileInputStream_L.b (1 of 18352 files). Show all

Unified · Split

java/pkg2/java/io/FileInputStream_L.b+135−0
@@ -0,0 +1,135 @@
1implement FileInputStream_L;
2
3# javal v1.3 generated file: edit with care
4
5include "jni.m";
6 jni : JNI;
7 ClassModule,
8 JString,
9 JArray,
10 JArrayI,
11 JArrayC,
12 JArrayB,
13 JArrayS,
14 JArrayJ,
15 JArrayF,
16 JArrayD,
17 JArrayZ,
18 JArrayJObject,
19 JArrayJClass,
20 JArrayJString,
21 JClass,
22 JThread,
23 JObject : import jni;
24
25#>> extra pre includes here
26 sys : import jni;
27 FALSE : import jni;
28 TRUE : import jni;
29include "FileDescriptor_L.m";
30 FileDescriptor_obj : import FileDescriptor_L;
31#<<
32
33include "FileInputStream_L.m";
34
35#>> extra post includes here
36#<<
37
38init( jni_p : JNI )
39{
40 # save java native inteface mod instance
41 jni = jni_p;
42 #>>extra initialization here
43 sys = jni->sys;
44 #<<
45}
46
47open_rString_V( this : ref FileInputStream_obj, p0 : JString)
48{#>>
49 # p0 == file name
50
51 if ((p0 == nil) || (p0.str == nil))
52 jni->ThrowException("java.lang.NullPointerException", "str is nil");
53
54 this.fd.fd = sys->open(p0.str, sys->OREAD);
55 if(this.fd.fd == nil)
56 jni->ThrowException("java.io.IOException", "open error");
57}#<<
58
59read_I( this : ref FileInputStream_obj) : int
60{#>>
61 buf := array[1] of byte;
62
63 if (this.fd.fd == nil)
64 jni->ThrowException("java.lang.NullPointerException", "null FileDescriptor");
65 readin := sys->read(this.fd.fd, buf, 1);
66 if (readin == 0) # EOF
67 return -1;
68
69 if (readin < 0)
70 jni->ThrowException("java.io.IOException", sys->sprint("%r"));
71 return (int buf[0]);
72
73}#<<
74
75readBytes_aB_I_I_I( this : ref FileInputStream_obj, p0 : JArrayB,p1 : int,p2 : int) : int
76{#>>
77 # p0 == input buffer (array of bytes)
78 # p1 == offset
79 # p2 == length
80 # read p2 bytes from the file and place them at location (p0 + p1)
81
82 if (this.fd == nil)
83 jni->ThrowException("java.lang.NullPointerException", "null FileDescriptor");
84 if ((p0 == nil) || (p0.ary == nil))
85 jni->ThrowException("java.lang.NullPointerException", "nil buffer pointer");
86 if ((p1 < 0) || (p1 > len p0.ary))
87 jni->ThrowException("java.lang.ArrayIndexOutOfBoundsException",
88 jni->sys->sprint( "offset=%d len buf array=%d", p1, len p0.ary));
89
90 if ((p1 + p2) > len p0.ary)
91 p2 = (len p0.ary) - p1;
92 if (p2 <= 0)
93 return 0;
94
95 n := sys->read(this.fd.fd, p0.ary[p1: len p0.ary], p2);
96 if (n == 0) # EOF
97 return -1;
98
99 if (n < 0)
100 jni->ThrowException("java.io.IOException", sys->sprint("%r"));
101 return n;
102}#<<
103
104skip_J_J( this : ref FileInputStream_obj, p0 : big) : big
105{#>>
106 # skip the next p0 bytes from the Input stream. First find out where you are in
107 # the stream. Next skip the bytes then return the "actual" bytes skipped.
108
109 if (this.fd.fd == nil)
110 jni->ThrowException("java.lang.NullPointerException", "null FileDescriptor");
111 cur := sys->seek(this.fd.fd, 0, sys->SEEKRELA);
112 end := sys->seek(this.fd.fd, (int p0), sys->SEEKRELA);
113 return big (end - cur);
114}#<<
115
116available_I( this : ref FileInputStream_obj) : int
117{#>>
118 if (this.fd.fd == nil)
119 jni->ThrowException("java.lang.NullPointerException", "null FileDescriptor");
120 cur := sys->seek(this.fd.fd, 0, Sys->SEEKRELA);
121 end := sys->seek(this.fd.fd, 0, Sys->SEEKEND);
122 sys->seek(this.fd.fd, cur, Sys->SEEKSTART);
123
124 return (end - cur);
125}#<<
126
127close_V( this : ref FileInputStream_obj)
128{#>>
129 if (this.fd != nil)
130 this.fd.fd = nil;
131}#<<
132
133
134
135