test_class.declarator: folder = StoreLocation.getTemporaryFolder()
test_class.modifier: @Rule
  	public
test_class.original_string: @Rule
  	public TemporaryFolder folder = StoreLocation.getTemporaryFolder();
test_class.type: TemporaryFolder
test_class.var_name: folder
test_class.file: cache/src/test/java/net/runelite/cache/fs/jagex/DiskStorageTest.java
test_class.identifier: DiskStorageTest
test_case.body: @Test
  	public void testSaveArchive() throws Exception
  	{
  		File file = folder.newFolder();
  		DiskStorage storage = new DiskStorage(file);
  		Archive archive;
  		Archive archive2;
  		try (Store store = new Store(storage))
  		{
  			Index index = store.addIndex(0);
  			archive = index.addArchive(0);
  			archive2 = index.addArchive(1);
  
  			FileData[] fileData = new FileData[1];
  			archive.setFileData(fileData);
  			fileData[0] = new FileData();
  
  			FileData[] fileData2 = new FileData[1];
  			archive2.setFileData(fileData2);
  			fileData2[0] = new FileData();
  
  			byte[] data = "test".getBytes();
  			Container container = new Container(archive.getCompression(), -1);
  			container.compress(data, null);
  			byte[] compressedData = container.data;
  			storage.saveArchive(archive, compressedData);
  
  			container = new Container(archive.getCompression(), 42);
  			container.compress(data, null);
  			compressedData = container.data;
  			archive2.setRevision(42);
  			storage.saveArchive(archive2, compressedData);
  
  			store.save();
  		}
  
  		storage = new DiskStorage(file);
  		try (Store store = new Store(storage))
  		{
  			store.load();
  			Index index = store.findIndex(0);
  			Archive archive2_1 = index.getArchive(0);
  			Archive archive2_2 = index.getArchive(1);
  
  			byte[] comprsesedData = storage.loadArchive(archive2_1);
  			byte[] data = archive2_1.decompress(comprsesedData);
  			assertArrayEquals("test".getBytes(), data);
  			assertEquals(archive.getCrc(), archive2_1.getCrc());
  			assertEquals(archive.getRevision(), archive2_1.getRevision());
  
  			comprsesedData = storage.loadArchive(archive2_2);
  			data = archive2_2.decompress(comprsesedData);
  			assertArrayEquals("test".getBytes(), data);
  			assertEquals(archive2.getCrc(), archive2_2.getCrc());
  			assertEquals(archive2.getRevision(), archive2_2.getRevision());
  		}
  	}
test_case.class_method_signature: DiskStorageTest.testSaveArchive()
test_case.full_signature: @Test public void testSaveArchive()
test_case.identifier: testSaveArchive
test_case.invocations: newFolder addIndex addArchive addArchive setFileData setFileData getBytes getCompression compress saveArchive getCompression compress setRevision saveArchive save load findIndex getArchive getArchive loadArchive decompress assertArrayEquals getBytes assertEquals getCrc getCrc assertEquals getRevision getRevision loadArchive decompress assertArrayEquals getBytes assertEquals getCrc getCrc assertEquals getRevision getRevision
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testSaveArchive()
focal_class.declarator: logger = LoggerFactory.getLogger(DiskStorage.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(DiskStorage.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: MAIN_FILE_CACHE_DAT = "main_file_cache.dat2"
focal_class.modifier: private static final
focal_class.original_string: private static final String MAIN_FILE_CACHE_DAT = "main_file_cache.dat2";
focal_class.type: String
focal_class.var_name: MAIN_FILE_CACHE_DAT
focal_class.declarator: MAIN_FILE_CACHE_IDX = "main_file_cache.idx"
focal_class.modifier: private static final
focal_class.original_string: private static final String MAIN_FILE_CACHE_IDX = "main_file_cache.idx";
focal_class.type: String
focal_class.var_name: MAIN_FILE_CACHE_IDX
focal_class.declarator: folder
focal_class.modifier: private final
focal_class.original_string: private final File folder;
focal_class.type: File
focal_class.var_name: folder
focal_class.declarator: data
focal_class.modifier: private final
focal_class.original_string: private final DataFile data;
focal_class.type: DataFile
focal_class.var_name: data
focal_class.declarator: index255
focal_class.modifier: private final
focal_class.original_string: private final IndexFile index255;
focal_class.type: IndexFile
focal_class.var_name: index255
focal_class.declarator: indexFiles = new ArrayList<>()
focal_class.modifier: private final
focal_class.original_string: private final List<IndexFile> indexFiles = new ArrayList<>();
focal_class.type: List<IndexFile>
focal_class.var_name: indexFiles
focal_class.file: cache/src/main/java/net/runelite/cache/fs/jagex/DiskStorage.java
focal_class.identifier: DiskStorage
focal_class.interfaces: implements Storage
focal_class.class_method_signature: DiskStorage.DiskStorage(File folder)
focal_class.full_signature: public  DiskStorage(File folder)
focal_class.identifier: DiskStorage
focal_class.modifiers: public
focal_class.parameters: (File folder)
focal_class.signature:  DiskStorage(File folder)
focal_class.class_method_signature: DiskStorage.init(Store store)
focal_class.full_signature: @Override public void init(Store store)
focal_class.identifier: init
focal_class.modifiers: @Override public
focal_class.parameters: (Store store)
focal_class.return: void
focal_class.signature: void init(Store store)
focal_class.class_method_signature: DiskStorage.close()
focal_class.full_signature: @Override public void close()
focal_class.identifier: close
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void close()
focal_class.class_method_signature: DiskStorage.getIndex(int i)
focal_class.full_signature: private IndexFile getIndex(int i)
focal_class.identifier: getIndex
focal_class.modifiers: private
focal_class.parameters: (int i)
focal_class.return: IndexFile
focal_class.signature: IndexFile getIndex(int i)
focal_class.class_method_signature: DiskStorage.load(Store store)
focal_class.full_signature: @Override public void load(Store store)
focal_class.identifier: load
focal_class.modifiers: @Override public
focal_class.parameters: (Store store)
focal_class.return: void
focal_class.signature: void load(Store store)
focal_class.class_method_signature: DiskStorage.readIndex(int indexId)
focal_class.full_signature: public byte[] readIndex(int indexId)
focal_class.identifier: readIndex
focal_class.modifiers: public
focal_class.parameters: (int indexId)
focal_class.return: byte[]
focal_class.signature: byte[] readIndex(int indexId)
focal_class.class_method_signature: DiskStorage.loadIndex(Index index)
focal_class.full_signature: private void loadIndex(Index index)
focal_class.identifier: loadIndex
focal_class.modifiers: private
focal_class.parameters: (Index index)
focal_class.return: void
focal_class.signature: void loadIndex(Index index)
focal_class.class_method_signature: DiskStorage.loadArchive(Archive archive)
focal_class.full_signature: @Override public byte[] loadArchive(Archive archive)
focal_class.identifier: loadArchive
focal_class.modifiers: @Override public
focal_class.parameters: (Archive archive)
focal_class.return: byte[]
focal_class.signature: byte[] loadArchive(Archive archive)
focal_class.class_method_signature: DiskStorage.save(Store store)
focal_class.full_signature: @Override public void save(Store store)
focal_class.identifier: save
focal_class.modifiers: @Override public
focal_class.parameters: (Store store)
focal_class.return: void
focal_class.signature: void save(Store store)
focal_class.class_method_signature: DiskStorage.saveIndex(Index index)
focal_class.full_signature: private void saveIndex(Index index)
focal_class.identifier: saveIndex
focal_class.modifiers: private
focal_class.parameters: (Index index)
focal_class.return: void
focal_class.signature: void saveIndex(Index index)
focal_class.class_method_signature: DiskStorage.saveArchive(Archive a, byte[] archiveData)
focal_class.full_signature: @Override public void saveArchive(Archive a, byte[] archiveData)
focal_class.identifier: saveArchive
focal_class.modifiers: @Override public
focal_class.parameters: (Archive a, byte[] archiveData)
focal_class.return: void
focal_class.signature: void saveArchive(Archive a, byte[] archiveData)
focal_method.body: @Override
  	public void saveArchive(Archive a, byte[] archiveData) throws IOException
  	{
  		Index index = a.getIndex();
  		IndexFile indexFile = getIndex(index.getId());
  		assert indexFile.getIndexFileId() == index.getId();
  
  		DataFileWriteResult res = data.write(index.getId(), a.getArchiveId(), archiveData);
  		indexFile.write(new IndexEntry(indexFile, a.getArchiveId(), res.sector, res.compressedLength));
  
  		byte compression = archiveData[0];
  		int compressedSize = Ints.fromBytes(archiveData[1], archiveData[2],
  			archiveData[3], archiveData[4]);
  
  		// don't crc the appended revision, if it is there
  		int length = 1 // compression type
  			+ 4 // compressed size
  			+ compressedSize
  			+ (compression != CompressionType.NONE ? 4 : 0);
  
  		Crc32 crc = new Crc32();
  		crc.update(archiveData, 0, length);
  		a.setCrc(crc.getHash());
  
  		logger.trace("Saved archive {}/{} at sector {}, compressed length {}",
  			index.getId(), a.getArchiveId(), res.sector, res.compressedLength);
  	}
focal_method.class_method_signature: DiskStorage.saveArchive(Archive a, byte[] archiveData)
focal_method.full_signature: @Override public void saveArchive(Archive a, byte[] archiveData)
focal_method.identifier: saveArchive
focal_method.invocations: getIndex getIndex getId getIndexFileId getId write getId getArchiveId write getArchiveId fromBytes update setCrc getHash trace getId getArchiveId
focal_method.modifiers: @Override public
focal_method.parameters: (Archive a, byte[] archiveData)
focal_method.return: void
focal_method.signature: void saveArchive(Archive a, byte[] archiveData)