mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Small code change
This commit is contained in:
@@ -25,9 +25,9 @@ import java.util.Arrays;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
|
||||||
/** Little endian version of the DataInputStream
|
/**
|
||||||
|
* Little endian version of the DataInputStream
|
||||||
* @author bpellin
|
* @author bpellin
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class LEDataInputStream extends InputStream {
|
public class LEDataInputStream extends InputStream {
|
||||||
|
|
||||||
@@ -35,17 +35,16 @@ public class LEDataInputStream extends InputStream {
|
|||||||
|
|
||||||
private InputStream baseStream;
|
private InputStream baseStream;
|
||||||
|
|
||||||
public LEDataInputStream(InputStream in) {
|
public LEDataInputStream(InputStream inputStream) {
|
||||||
baseStream = in;
|
baseStream = inputStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Read a 32-bit value and return it as a long, so that it can
|
/**
|
||||||
|
* Read a 32-bit value and return it as a long, so that it can
|
||||||
* be interpreted as an unsigned integer.
|
* be interpreted as an unsigned integer.
|
||||||
* @return
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
*/
|
||||||
public long readUInt() throws IOException {
|
public long readUInt() throws IOException {
|
||||||
return readUInt(baseStream);
|
return readInt(baseStream) & INT_TO_LONG_MASK;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int readInt() throws IOException {
|
public int readInt() throws IOException {
|
||||||
@@ -54,7 +53,6 @@ public class LEDataInputStream extends InputStream {
|
|||||||
|
|
||||||
public long readLong() throws IOException {
|
public long readLong() throws IOException {
|
||||||
byte[] buf = readBytes(8);
|
byte[] buf = readBytes(8);
|
||||||
|
|
||||||
return readLong(buf, 0);
|
return readLong(buf, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,60 +151,40 @@ public class LEDataInputStream extends InputStream {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int readUShort(InputStream is) throws IOException {
|
|
||||||
byte[] buf = new byte[2];
|
|
||||||
|
|
||||||
is.read(buf, 0, 2);
|
|
||||||
|
|
||||||
return readUShort(buf, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int readUShort() throws IOException {
|
public int readUShort() throws IOException {
|
||||||
return readUShort(baseStream);
|
byte[] buf = new byte[2];
|
||||||
|
baseStream.read(buf, 0, 2);
|
||||||
|
return readUShort(buf, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read an unsigned 16-bit value.
|
* Read an unsigned 16-bit value.
|
||||||
*
|
|
||||||
* @param buf
|
|
||||||
* @param offset
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public static int readUShort( byte[] buf, int offset ) {
|
public static int readUShort( byte[] buf, int offset ) {
|
||||||
return (buf[offset] & 0xFF) + ((buf[offset + 1] & 0xFF) << 8);
|
return (buf[offset] & 0xFF) + ((buf[offset + 1] & 0xFF) << 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long readLong( byte buf[], int offset ) {
|
public static long readLong(byte[] buf, int offset ) {
|
||||||
return ((long)buf[offset] & 0xFF) + (((long)buf[offset + 1] & 0xFF) << 8)
|
return ((long)buf[offset] & 0xFF) + (((long)buf[offset + 1] & 0xFF) << 8)
|
||||||
+ (((long)buf[offset + 2] & 0xFF) << 16) + (((long)buf[offset + 3] & 0xFF) << 24)
|
+ (((long)buf[offset + 2] & 0xFF) << 16) + (((long)buf[offset + 3] & 0xFF) << 24)
|
||||||
+ (((long)buf[offset + 4] & 0xFF) << 32) + (((long)buf[offset + 5] & 0xFF) << 40)
|
+ (((long)buf[offset + 4] & 0xFF) << 32) + (((long)buf[offset + 5] & 0xFF) << 40)
|
||||||
+ (((long)buf[offset + 6] & 0xFF) << 48) + (((long)buf[offset + 7] & 0xFF) << 56);
|
+ (((long)buf[offset + 6] & 0xFF) << 48) + (((long)buf[offset + 7] & 0xFF) << 56);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long readUInt( byte buf[], int offset ) {
|
public static long readUInt(byte[] buf, int offset ) {
|
||||||
return (readInt(buf, offset) & INT_TO_LONG_MASK);
|
return (readInt(buf, offset) & INT_TO_LONG_MASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int readInt(InputStream is) throws IOException {
|
public static int readInt(InputStream is) throws IOException {
|
||||||
byte[] buf = new byte[4];
|
byte[] buf = new byte[4];
|
||||||
|
|
||||||
is.read(buf, 0, 4);
|
is.read(buf, 0, 4);
|
||||||
|
|
||||||
return readInt(buf, 0);
|
return readInt(buf, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long readUInt(InputStream is) throws IOException {
|
|
||||||
return (readInt(is) & INT_TO_LONG_MASK);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read a 32-bit value.
|
* Read a 32-bit value.
|
||||||
*
|
|
||||||
* @param buf
|
|
||||||
* @param offset
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public static int readInt( byte buf[], int offset ) {
|
public static int readInt(byte[] buf, int offset ) {
|
||||||
return (buf[offset] & 0xFF) + ((buf[offset + 1] & 0xFF) << 8) + ((buf[offset + 2] & 0xFF) << 16)
|
return (buf[offset] & 0xFF) + ((buf[offset + 1] & 0xFF) << 8) + ((buf[offset + 2] & 0xFF) << 16)
|
||||||
+ ((buf[offset + 3] & 0xFF) << 24);
|
+ ((buf[offset + 3] & 0xFF) << 24);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user