package com; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.DataInput; import java.io.DataInputStream; import java.io.DataOutput; import java.io.DataOutputStream; import java.io.EOFException; import java.io.IOException; import javax.microedition.rms.InvalidRecordIDException; import javax.microedition.rms.RecordStore; import javax.microedition.rms.RecordStoreException; import javax.microedition.rms.RecordStoreFullException; import javax.microedition.rms.RecordStoreNotFoundException; public final class RandomAccessFile implements DataInput, DataOutput { public RecordStore var_28; public byte[] var_6c; public boolean var_9b; public int var_f5; public int var_14c; public int var_178; public int var_1c8; public int var_1fb = 256; private void sub_4d(int var1) { try { this.var_6c = this.var_28.getRecord(var1); } catch (RecordStoreException var2) { this.var_6c = new byte[this.var_1fb]; } } private void sub_7d(int var1) { try { this.var_28.setRecord(var1, this.var_6c, 0, this.var_1fb); } catch (InvalidRecordIDException var6) { try { while (this.var_28.addRecord(this.var_6c, 0, this.var_1fb) != var1) { ; } } catch (RecordStoreFullException var4) { throw new BasicError(4101, "Disk full"); } catch (Exception var5) { throw new BasicError(4101, var5.getClass().getName()); } } catch (RecordStoreFullException var7) { throw new BasicError(4101, "Disk full"); } catch (Exception var8) { throw new BasicError(4101, var8.getClass().getName()); } } public RandomAccessFile(String var1, boolean var2) { try { this.var_28 = RecordStore.openRecordStore(var1, false); this.var_6c = null; this.var_f5 = 0; this.var_9b = false; this.var_1c8 = 0; this.var_178 = 8; this.var_14c = this.readInt(); if (this.var_14c == 1379991553) { this.var_178 = this.readInt(); this.var_1c8 = 8; } else { this.var_178 = this.var_6c.length; this.var_1fb = this.var_178; this.var_1c8 = 0; } } catch (RecordStoreNotFoundException var5) { if (!var2) { try { this.var_28 = RecordStore.openRecordStore(var1, true); this.var_6c = null; this.var_f5 = 0; this.var_9b = false; this.var_178 = 8; this.var_1c8 = 8; this.var_14c = 1379991553; } catch (Exception var4) { throw new BasicError(4101, var5.getClass().getName()); } } else { throw new BasicError(4100, "\"" + var1 + "\" not found"); } } catch (Exception var6) { throw new BasicError(4101, var6.getClass().getName()); } } public final void sub_b3() { if (this.var_14c == 1379991553) { this.var_1c8 = 0; this.writeInt(1379991553); this.writeInt(this.var_178); this.sub_7d(this.var_f5); } try { this.var_28.closeRecordStore(); } catch (RecordStoreException var1) { ; } } public final byte readByte() throws EOFException { if (this.var_1c8 >= 0) { if (this.var_1c8 < this.var_178) { int var2 = this.var_1c8 / this.var_1fb + 1; int var3 = this.var_1c8 % this.var_1fb; if (var2 != this.var_f5) { if (this.var_9b) { this.sub_7d(this.var_f5); } this.sub_4d(var2); this.var_f5 = var2; this.var_9b = false; } byte var1 = this.var_6c[var3]; ++this.var_1c8; return var1; } else { throw new EOFException(); } } else { throw new BasicError(4101, "Invalid offset"); } } public final void writeByte(int var1) { if (this.var_1c8 >= 0) { int var2 = this.var_1c8 / this.var_1fb + 1; int var3 = this.var_1c8 % this.var_1fb; if (var2 != this.var_f5) { if (this.var_9b) { this.sub_7d(this.var_f5); } this.sub_4d(var2); this.var_f5 = var2; this.var_9b = false; } this.var_6c[var3] = (byte) var1; this.var_9b = true; ++this.var_1c8; if (this.var_1c8 >= this.var_178) { this.var_178 = this.var_1c8; } } else { throw new BasicError(4101, "Invalid offset"); } } public final boolean readBoolean() throws IOException { throw new IOException("function not implemented"); } public final char readChar() throws IOException { throw new IOException("function not implemented"); } public final void readFully(byte[] var1) throws EOFException { for (int var2 = 0; var2 < var1.length; ++var2) { var1[var2] = this.readByte(); } } public final void readFully(byte[] var1, int var2, int var3) throws EOFException { for (int var4 = var2; var4 < var3; ++var4) { var1[var4] = this.readByte(); } } public final int readInt() throws EOFException { byte var1 = this.readByte(); byte var2 = this.readByte(); byte var3 = this.readByte(); byte var4 = this.readByte(); return (var1 & 255) << 24 | (var2 & 255) << 16 | (var3 & 255) << 8 | var4 & 255; } public final long readLong() throws IOException { throw new IOException("function not implemented"); } public final short readShort() throws EOFException { byte var1 = this.readByte(); byte var2 = this.readByte(); return (short) ((var1 & 255) << 8 | var2 & 255); } public final int readUnsignedByte() throws IOException { throw new IOException("function not implemented"); } public final int readUnsignedShort() throws EOFException { byte var1 = this.readByte(); byte var2 = this.readByte(); return (var1 & 255) << 8 | var2 & 255; } public final String readUTF() throws IOException { int var2 = this.var_1c8; int var3 = this.readUnsignedShort(); this.var_1c8 = var2; byte[] var4 = new byte[var3 + 2]; this.readFully(var4); ByteArrayInputStream var5 = new ByteArrayInputStream(var4); return (new DataInputStream(var5)).readUTF(); } public final int skipBytes(int var1) throws IOException { throw new IOException("function not implemented"); } public final void write(byte[] var1) throws IOException { throw new IOException("function not implemented"); } public final void write(byte[] var1, int var2, int var3) { for (int var4 = var2; var4 < var3; ++var4) { this.writeByte(var1[var4]); } } public final void write(int var1) throws IOException { throw new IOException("function not implemented"); } public final void writeBoolean(boolean var1) throws IOException { throw new IOException("function not implemented"); } public final void writeChar(int var1) throws IOException { throw new IOException("function not implemented"); } public final void writeChars(String var1) throws IOException { throw new IOException("function not implemented"); } public final void writeInt(int var1) { this.writeByte(var1 >> 24 & 255); this.writeByte(var1 >> 16 & 255); this.writeByte(var1 >> 8 & 255); this.writeByte(var1 & 255); } public final void writeLong(long var1) throws IOException { throw new IOException("function not implemented"); } public final void writeShort(int var1) { this.writeByte(var1 >> 8 & 255); this.writeByte(var1 & 255); } public final void writeUTF(String var1) throws IOException { ByteArrayOutputStream var2 = new ByteArrayOutputStream(); (new DataOutputStream(var2)).writeUTF(var1); byte[] var4 = var2.toByteArray(); for (int var5 = 0; var5 < var4.length; ++var5) { this.writeByte(var4[var5]); } } public final int getFilePointer() { return this.var_1c8 - 8; } public final void seek(int var1) { if (var1 >= 0) { this.var_1c8 = var1 + 8; if (this.var_1c8 <= this.var_178) { return; } } this.var_1c8 = this.var_178; } public double readDouble() throws IOException { throw new UnsupportedOperationException("Not supported yet."); } public float readFloat() throws IOException { throw new UnsupportedOperationException("Not supported yet."); } public void writeDouble(double v) throws IOException { throw new UnsupportedOperationException("Not supported yet."); } public void writeFloat(float v) throws IOException { throw new UnsupportedOperationException("Not supported yet."); } }