private StorageItem <T> ReadMetaData(FileStream fs, out int metasize) { byte[] hdr = new byte[5]; // read header fs.Read(hdr, 0, 5); // meta length int len = Helper.ToInt32(hdr, 1); int type = hdr[0]; if (type > 0) { metasize = len + 5; hdr = new byte[len]; fs.Read(hdr, 0, len); StorageItem <T> meta; if (type == 1) { meta = fastBinaryJSON.BJSON.ToObject <StorageItem <T> >(hdr); } else { string str = Helper.GetString(hdr, 0, (short)hdr.Length); meta = fastJSON.JSON.ToObject <StorageItem <T> >(str); } return(meta); } else { metasize = len; return(null); } }
private int ParseBlockHeader(AllocationBlock ab, byte[] b, int blocknumberexpected) { int bnum = Helper.ToInt32(b, 0); if (bnum != blocknumberexpected) { _log.Error("Block numbers does not match, looking for : " + blocknumberexpected); //throw new Exception("Block numbers does not match, looking for : " + blocknumberexpected); return(-1); } if (b[14] != 1) { _log.Error("Expecting string keys only, got : " + b[14]); //throw new Exception("Expecting string keys only, got : " + b[11]); return(-1); } int next = Helper.ToInt32(b, 4); if (ab.keylen == 0) { byte flags = b[8]; if ((flags & 0x01) > 0) { ab.isCompressed = true; } if ((flags & 0x02) > 0) { ab.isBinaryJSON = true; } if ((flags & 0x04) > 0) { ab.deleteKey = true; } ab.datalength = Helper.ToInt32(b, 9); byte keylen = b[13]; ab.keylen = keylen; ab.key = Helper.GetString(b, _blockheader.Length, keylen); } return(next); }
public string GetObject(byte[] buffer, int offset, int count) { return(Helper.GetString(buffer, offset, (short)count)); }