Showing the changes to java/pkg2/java/io/RandomAccessFile_L.b (1 of 18352 files). Show all
Unified · Split
| @@ -0,0 +1,190 @@ | ||
| 1 | +implement RandomAccessFile_L; | |
| 2 | + | |
| 3 | +# javal v1.3 generated file: edit with care | |
| 4 | + | |
| 5 | +include "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; | |
| 29 | +include "FileDescriptor_L.m"; | |
| 30 | + FileDescriptor_obj : import FileDescriptor_L; | |
| 31 | +#<< | |
| 32 | + | |
| 33 | +include "RandomAccessFile_L.m"; | |
| 34 | + | |
| 35 | +#>> extra post includes here | |
| 36 | +#<< | |
| 37 | + | |
| 38 | +init( 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 | + | |
| 47 | +open_rString_Z_V( this : ref RandomAccessFile_obj, p0 : JString,p1 : int) | |
| 48 | +{#>> | |
| 49 | + # p0 == file name | |
| 50 | + # p1 == writable flag | |
| 51 | + | |
| 52 | + if ((this.fd == nil) || (p0 == nil) || (p0.str == nil)) | |
| 53 | + jni->ThrowException("java.lang.NullPointerException", "null path name"); | |
| 54 | + | |
| 55 | + if (p1 == TRUE){ | |
| 56 | + this.fd.fd = sys->open(p0.str, sys->ORDWR); | |
| 57 | + if(this.fd.fd == nil) | |
| 58 | + this.fd.fd = sys->create(p0.str, Sys->ORDWR, 8r640); | |
| 59 | + } | |
| 60 | + else | |
| 61 | + this.fd.fd = sys->open(p0.str, sys->OREAD); | |
| 62 | + | |
| 63 | + if(this.fd.fd == nil) | |
| 64 | + jni->ThrowException("java.io.IOException", sys->sprint("%r")); | |
| 65 | +}#<< | |
| 66 | + | |
| 67 | +read_I( this : ref RandomAccessFile_obj) : int | |
| 68 | +{#>> | |
| 69 | + buf := array[1] of byte; | |
| 70 | + | |
| 71 | + if ((this.fd == nil) || (this.fd.fd == nil)) | |
| 72 | + jni->ThrowException("java.lang.NullPointerException", "null FileDescriptor"); | |
| 73 | + | |
| 74 | + readin := sys->read(this.fd.fd, buf, 1); | |
| 75 | + if (readin == 0) # EOF | |
| 76 | + return -1; | |
| 77 | + | |
| 78 | + if (readin < 0) | |
| 79 | + jni->ThrowException("java.io.IOException", sys->sprint("%r")); | |
| 80 | + return (int buf[0]); | |
| 81 | +}#<< | |
| 82 | + | |
| 83 | +FD: import Sys; | |
| 84 | +stderr: ref FD; | |
| 85 | +readBytes_aB_I_I_I( this : ref RandomAccessFile_obj, p0 : JArrayB,p1 : int,p2 : int) : int | |
| 86 | +{#>> | |
| 87 | + # p0 == buffer for read in data | |
| 88 | + # p1 == offset in buffer to start to place data | |
| 89 | + # p2 == amount of data to read in | |
| 90 | + | |
| 91 | + if ((this.fd == nil) || (this.fd.fd == nil)) | |
| 92 | + jni->ThrowException("java.lang.NullPointerException", "null FileDescriptor"); | |
| 93 | + | |
| 94 | + if ((p0 == nil) || (p0.ary == nil)) | |
| 95 | + jni->ThrowException("java.lang.NullPointerException", "null array"); | |
| 96 | + | |
| 97 | + if ((p1 < 0) || (p1 > len p0.ary)) | |
| 98 | + jni->ThrowException("java.lang.ArrayIndexOutOfBoundsException", nil); | |
| 99 | + | |
| 100 | + if ((p1 + p2) > len p0.ary) | |
| 101 | + p2 = (len p0.ary) - p1; | |
| 102 | + | |
| 103 | + if (p2 <= 0) | |
| 104 | + jni->ThrowException("java.lang.ArrayIndexOutOfBoundsException", | |
| 105 | +nil); | |
| 106 | + | |
| 107 | + n := sys->read(this.fd.fd, p0.ary[p1:len p0.ary], p2); | |
| 108 | + if (n == 0) # EOF | |
| 109 | + return -1; | |
| 110 | + | |
| 111 | + if (n < 0) | |
| 112 | + jni->ThrowException("java.io.IOException", sys->sprint("%r")); | |
| 113 | + return n; | |
| 114 | +}#<< | |
| 115 | + | |
| 116 | +write_I_V( this : ref RandomAccessFile_obj, p0 : int) | |
| 117 | +{#>> | |
| 118 | + c := array[1] of byte; | |
| 119 | + c[0] = byte p0; | |
| 120 | + | |
| 121 | + if ((this.fd == nil) || (this.fd.fd == nil)) | |
| 122 | + jni->ThrowException("java.lang.NullPointerException", "null FileDescriptor"); | |
| 123 | + | |
| 124 | + if (sys->write(this.fd.fd, c, 1) != 1) | |
| 125 | + jni->ThrowException("java.io.IOException", sys->sprint("%r")); | |
| 126 | +}#<< | |
| 127 | + | |
| 128 | +writeBytes_aB_I_I_V( this : ref RandomAccessFile_obj, p0 : JArrayB,p1 : int,p2 : int) | |
| 129 | +{#>> | |
| 130 | + # p0 == buffer array to write from | |
| 131 | + # p1 == offset in buffer | |
| 132 | + # p2 == amount to write out | |
| 133 | + | |
| 134 | + if ((this.fd == nil) || (this.fd.fd == nil)) | |
| 135 | + jni->ThrowException("java.lang.NullPointerException", "null FileDescriptor"); | |
| 136 | + if ((p0 == nil) || (p0.ary == nil)) | |
| 137 | + jni->ThrowException("java.lang.NullPointerException", nil); | |
| 138 | + if ((p1 < 0) || (p2 < 0) || (p1 + p2 > (len p0.ary))) | |
| 139 | + jni->ThrowException("java.lang.ArrayIndexOutOfBoundsException", nil); | |
| 140 | + | |
| 141 | + n := 0; | |
| 142 | + while (p2 > 0) { | |
| 143 | + n = sys->write(this.fd.fd, p0.ary[p1:len p0.ary], p2); | |
| 144 | + if (n == -1) { | |
| 145 | + jni->ThrowException("java.io.IOException", sys->sprint("%r")); | |
| 146 | + break; | |
| 147 | + } | |
| 148 | + p1 += n; | |
| 149 | + p2 -= n; | |
| 150 | + } | |
| 151 | +}#<< | |
| 152 | + | |
| 153 | +getFilePointer_J( this : ref RandomAccessFile_obj) : big | |
| 154 | +{#>> | |
| 155 | + if (this.fd == nil) | |
| 156 | + jni->ThrowException("java.io.IOException", "this.fd nil"); | |
| 157 | + cur := sys->seek(this.fd.fd, 0, sys->SEEKRELA); | |
| 158 | + if (cur < 0) | |
| 159 | + jni->ThrowException("java.io.IOException", sys->sprint("%r")); | |
| 160 | + return (big cur); | |
| 161 | +}#<< | |
| 162 | + | |
| 163 | +seek_J_V( this : ref RandomAccessFile_obj, p0 : big) | |
| 164 | +{#>> | |
| 165 | + if (this.fd == nil) | |
| 166 | + jni->ThrowException("java.io.IOException", "this.fd nil"); | |
| 167 | + sys->seek(this.fd.fd, (int p0), sys->SEEKSTART); | |
| 168 | +}#<< | |
| 169 | + | |
| 170 | +length_J( this : ref RandomAccessFile_obj) : big | |
| 171 | +{#>> | |
| 172 | + if (this.fd == nil) | |
| 173 | + jni->ThrowException("java.io.IOException", "this.fd nil"); | |
| 174 | + cur := sys->seek(this.fd.fd, 0, sys->SEEKRELA); | |
| 175 | + end := sys->seek(this.fd.fd, 0, sys->SEEKEND); | |
| 176 | + sys->seek(this.fd.fd, cur, sys->SEEKSTART); | |
| 177 | + | |
| 178 | + return (big end); | |
| 179 | +}#<< | |
| 180 | + | |
| 181 | +close_V( this : ref RandomAccessFile_obj) | |
| 182 | +{#>> | |
| 183 | + if (this.fd != nil) | |
| 184 | + this.fd.fd = nil; | |
| 185 | +}#<< | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |