public int read() throws SmbException { if( read( tmp, 0, 1 ) == -1 ) { return -1; } return tmp[0] & 0xFF; } public int read( byte b[] ) throws SmbException {
public final void writeBoolean( boolean v ) throws SmbException { tmp[0] = (byte)(v ? 1 : 0); write( tmp, 0, 1 ); } public final void writeByte( int v ) throws SmbException {
public final void readFully( byte b[] ) throws SmbException { readFully( b, 0, b.length ); } public final void readFully( byte b[], int off, int len ) throws SmbException {
@Override public int available() throws IOException { final long available = raf.length() - raf.getFilePointer(); if (available > Integer.MAX_VALUE) { return Integer.MAX_VALUE; } return (int) available; }
@Override public long skip(final long n) throws IOException { raf.seek(raf.getFilePointer() + n); return n; } };
public final String readUTF() throws SmbException { int size = readUnsignedShort(); byte[] b = new byte[size]; read( b, 0, size ); try { return Encdec.dec_utf8( b, 0, size ); } catch( IOException ioe ) { throw new SmbException( "", ioe ); } } public final void writeBoolean( boolean v ) throws SmbException {
@Override public final void writeUTF ( String str ) throws SmbException { int len = str.length(); int ch, size = 0; byte[] dst; for ( int i = 0; i < len; i++ ) { ch = str.charAt(i); size += ch > 0x07F ? ( ch > 0x7FF ? 3 : 2 ) : 1; } dst = new byte[size]; writeShort(size); Encdec.enc_utf8(str, dst, 0, size); write(dst, 0, size); }
@Override public SmbRandomAccessFile openRandomAccess ( String mode ) throws SmbException { return new SmbRandomAccessFile(this, mode); }
@Override public void writeShort(int v) throws IOException { raf.writeShort(v); }
public int readUnsignedShort() throws IOException { return raf.readUnsignedShort(); }
@Override public void close() throws IOException { raf.close(); }
@Override public void setLength(long newLength) throws IOException { raf.setLength(newLength); // jCIFS doesn't automatically position the offset to the end of the file when it is truncated. // We have to do it ourselves to honour this method's contract. if(getOffset()>newLength) raf.seek(newLength); } }
public long length() throws IOException { return raf.length(); }
public void seek(long offset) throws IOException { raf.seek(offset); } }
public long getOffset() throws IOException { return raf.getFilePointer(); }
public final String readUTF() throws SmbException { int size = readUnsignedShort(); byte[] b = new byte[size]; read( b, 0, size ); try { return Encdec.dec_utf8( b, 0, size ); } catch( IOException ioe ) { throw new SmbException( "", ioe ); } } public final void writeBoolean( boolean v ) throws SmbException {
@Override public final void writeUTF ( String str ) throws SmbException { int len = str.length(); int ch, size = 0; byte[] dst; for ( int i = 0; i < len; i++ ) { ch = str.charAt(i); size += ch > 0x07F ? ( ch > 0x7FF ? 3 : 2 ) : 1; } dst = new byte[size]; writeShort(size); Encdec.enc_utf8(str, dst, 0, size); write(dst, 0, size); }
@Override public SmbRandomAccessFile openRandomAccess ( String mode, int sharing ) throws SmbException { return new SmbRandomAccessFile(this, mode, sharing, false); }
@Override public void writeShort(final int v) throws IOException { raf.writeShort(v); }
public int readUnsignedShort() throws IOException { return raf.readUnsignedShort(); }