private FileStore(File directory) throws Exception {
		int filesLoaded = 0;
		for(File file : directory.listFiles()) {
			if(file.isFile()) {
				if(file.getName().equals("main_file_cache.dat2")) {
					dataFile = new RandomAccessFile(file, "r");
				} else {
					if(file.getName().startsWith("main_file_cache.idx")) {
						int id = Integer.parseInt(file.getName().substring(file.getName().indexOf(".idx") + 4, file.getName().length()));					
						if(id != 255) {
							indexes[id] = new RandomAccessFile(file, "r");
						} else {
							crcFile = new RandomAccessFile(file, "r");
						}
						filesLoaded++;
					}
				}
			}
		}
		for(int i = 0; i < indexes.length; i++) {
			RandomAccessFile idxs = indexes[i];
			if(idxs != null) {
				jagFS[i] = new JagFS(i, dataFile, idxs);
			}
		}
		if(crcFile != null) {
			jagCRC = new JagFS(255, dataFile, crcFile);
		}
		MessageBuilder crct = new MessageBuilder();
		crct.writeByte((byte) 255).writeShort((short) 255).
		writeByte((byte) 0).writeInt(jagCRC.getLength() * 8);
		CRC32 crcc = new CRC32();
		for (int i = 0; i < jagCRC.getLength(); i++) {
			crcc.update(jagCRC.get(i));
			crct.writeInt((int) crcc.getValue());
			crct.writeInt(0);
			crcc.reset();
		}
		crcPacket = crct.toMessage();
		logger.info("Loaded " + filesLoaded + " cache files.");
	}