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/FileOutputStream_L.b (1 of 18352 files). Show all

Unified · Split

java/pkg2/java/io/FileOutputStream_L.b+116−0
@@ -0,0 +1,116 @@
1implement FileOutputStream_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 "FileOutputStream_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 FileOutputStream_obj, p0 : JString)
48{#>>
49 # open file pointed to by p0. If it does not exists, create it and
50 # and open it with mode of 644.
51
52 if ((p0 == nil) || (p0.str == nil))
53 jni->ThrowException("java.lang.NullPointerException", "null file name");
54
55 this.fd.fd = sys->create(p0.str, sys->OWRITE, 8r666);
56 if(this.fd.fd == nil)
57 jni->ThrowException("java.io.IOException", sys->sprint("%r"));
58}#<<
59
60openAppend_rString_V( this : ref FileOutputStream_obj, p0 : JString)
61{#>>
62 if ((p0 == nil) || (p0.str == nil))
63 jni->ThrowException("java.lang.NullPointerException", "null filename");
64
65 this.fd.fd = sys->open(p0.str, sys->OWRITE);
66 if(this.fd.fd == nil)
67 jni->ThrowException("java.io.IOException", sys->sprint("%r"));
68 sys->seek(this.fd.fd, 0, sys->SEEKEND);
69}#<<
70
71write_I_V( this : ref FileOutputStream_obj, p0 : int)
72{#>>
73 # p0 == character to write
74 c := array[1] of byte;
75 c[0] = byte p0;
76
77 if ((this.fd == nil) || (this.fd.fd == nil))
78 jni->ThrowException("java.lang.NullPointerException", "null FileDescriptor");
79
80 if (sys->write(this.fd.fd, c, 1) != 1)
81 jni->ThrowException("java.io.IOException", sys->sprint("%r"));
82}#<<
83
84writeBytes_aB_I_I_V( this : ref FileOutputStream_obj, p0 : JArrayB,p1 : int,p2 : int)
85{#>>
86 # p0 == buffer array to write from
87 # p1 == offset in buffer
88 # p2 == length to write out
89
90 if ((this.fd == nil) || (this.fd.fd == nil))
91 jni->ThrowException("java.lang.NullPointerException", "null FileDescriptor");
92 if ((p0 == nil) || (p0.ary == nil))
93 jni->ThrowException("java.lang.NullPointerException", nil);
94 if ((p1 < 0) || (p2 < 0) || (p1 > (len p0.ary)))
95 jni->ThrowException("java.lang.ArrayIndexOutOfBoundsException", nil);
96
97 n := 0;
98 while (p2 > 0) {
99 # you can also write the following line as.....
100 # n = sys->write(this.fd.fd, p0.ary[p1:], p2);
101 n = sys->write(this.fd.fd, p0.ary[p1:len p0.ary], p2);
102 if (n == -1) {
103 jni->ThrowException("java.io.IOException", sys->sprint("%r"));
104 break;
105 }
106 p1 += n;
107 p2 -= n;
108 }
109}#<<
110
111close_V( this : ref FileOutputStream_obj)
112{#>>
113 if (this.fd != nil)
114 this.fd.fd = nil;
115}#<<
116