PageSourceSearch

https://kent.soke.bel.tr:90/Scripts/binarywrapper.js

js soke.bel.tr collected 2026-09-24 10:09:27 UTC 2,376 bytes, 82 lines download raw bytes

1//
2// stateful helper for binaryajax.js's BinaryFile class
3// 
4// modelled on Flash's ByteArray, mostly, although some names
5// (int/short/long) differ in definition
6//
7
8function BinaryFileWrapper(binFile) {
9    
10    this.position = 0;
11    this.bigEndian = true;
12
13    this.getByte = function() {
14        var byte = binFile.getByteAt(this.position);
15        this.position++;
16        return byte;
17    }
18
19    this.getLength = function() {
20        return binFile.getLength();
21    }
22
23    this.getSByte = function() {
24        var sbyte = binFile.getSByteAt(this.position);
25        this.position++;
26        return sbyte;
27    }
28
29    this.getShort = function() {
30        var short = binFile.getShortAt(this.position, this.bigEndian);
31        this.position += 2;
32        return short;
33    }
34    
35    this.getSShort = function() {
36        var sshort = binFile.getSShortAt(this.position, this.bigEndian);
37        this.position += 2;
38        return sshort;
39    }
40    
41    this.getLong = function() {
42        var l = binFile.getLongAt(this.position, this.bigEndian);
43        this.position += 4;
44        return l;
45    }
46    
47    this.getSLong = function() {
48        var l = binFile.getSLongAt(this.position, this.bigEndian);
49        this.position += 4;
50        return l;
51    }
52    
53    this.getString = function(iLength) {
54        var s = binFile.getStringAt(this.position, iLength);
55        this.position += iLength;
56        return s;
57    }
58
59	this.getDoubleAt = function(iOffset, bBigEndian) {
60		// hugs stackoverflow
61		// http://stackoverflow.com/questions/1597709/convert-a-string-with-a-hex-representation-of-an-ieee-754-double-into-javascript
62		// TODO: check the endianness for something other than shapefiles
63		// TODO: what about NaNs and Infinity?
64		var a = binFile.getLongAt(iOffset + (bBigEndian ? 0 : 4), bBigEndian);
65		var b = binFile.getLongAt(iOffset + (bBigEndian ? 4 : 0), bBigEndian);
66		var s = a >> 31 ? -1 : 1;
67		var e = (a >> 52 - 32 & 0x7ff) - 1023;
68		return s * (a & 0xfffff | 0x100000) * 1.0 / Math.pow(2,52-32) * Math.pow(2, e) + b * 1.0 / Math.pow(2, 52) * Math.pow(2, e);
69	}
70
71    this.getDouble = function() {    
72        var d = this.getDoubleAt(this.position, this.bigEndian);
73        this.position += 8;
74        return d;
75    }
76
77    this.getChar = function() {
78        var c = binFile.getCharAt(this.position);
79        this.position++;
80        return c;
81    }
82}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.