public XNBData read(boolean strict) throws XNBException,FileNotFoundException,IOException {
		XNBData data = new XNBData();
		
		BinBuffer binb = new BinFile(file).read();
		binb.setPos(0);
		if (!binb.readChars(3).equals("XNB")) throw new XNBException("Invalid file format.");
		
		data.targetPlatform = ETargetPlatform.getByChar((char)binb.readByte());
		if (data.targetPlatform == null || (strict && data.targetPlatform != ETargetPlatform.Windows)) throw new XNBException("Invalid platform.");
		
		data.formatVersion = binb.readByte();
		if (strict && data.formatVersion != 5) throw new XNBException("Unimplemented XNA version.");
		
		int b = binb.readByte();
		data.flagHiDef = (b & 0x01) != 0;
		data.flagCompressed = (b & 0x80) != 0;
		
		data.sizeTotal = (int)binb.readUInt();
		if (strict && data.sizeTotal != binb.getSize()) throw new XNBException("Corrupted file.");
		
		if (data.flagCompressed) {
			data.sizeDecompressed = (int)binb.readUInt();
			
			try {
				LZXDecoder decoder = new LZXDecoder(16);
				BinBuffer binb2 = new BinBuffer();
				int pos = binb.getPos();
				while (binb.bytesLeft() > 0) {
					int hi, lo, block_size, frame_size;
					hi = binb.readByte();
					
					if (hi == 0xFF) {
                        hi = binb.readByte();
                        lo = binb.readByte();
                        frame_size = (hi << 8) | lo;
                        hi = binb.readByte();
                        lo = binb.readByte();
                        block_size = (hi << 8) | lo;
                    } else {
                        lo = binb.readByte();
                        block_size = (hi << 8) | lo;
                        frame_size = 32768;
                    }
					
					if (block_size == 0 || frame_size == 0) break;
					decoder.Decompress(binb,block_size,binb2,frame_size);
					binb.setPos(pos);
				}
				binb2.setPos(0);
				binb = binb2;
			} catch (LZXException e) {App.getApp().handle(e);}
			
			if (strict && data.sizeDecompressed != binb.getSize()) throw new XNBException("Corrupted file.");
		}
		
		int count;
		
		count = read7BitEncodedInt(binb);
		if (count == 0) throw new XNBException("No readers.");
		if (strict && count > 1) throw new XNBException("Too many readers.");
		while (count-- > 0) data.readers.add(new Pair<String,Integer>(readCSharpString(binb),binb.readInt()));
		
		count = read7BitEncodedInt(binb);
		if (strict && count > 0) throw new XNBException("Too many shared resources.");
		
		XNBObjectReader<?> reader = getObjectReader(data.readers.get(0).get1());
		if (reader == null) throw new XNBException("No applicable readers for "+data.readers.get(0).get1()+".");
		
		data.assetData = reader.read(binb);
		while (count-- > 0) data.sharedResources.add(reader.read(binb));
		return data;
	}