Add alloc parameter to Store.open()

Signed-off-by: Graham <gpe@openrs2.dev>
bzip2
Graham 4 years ago
parent d2174bb77c
commit 15d359429e
  1. 9
      cache/src/main/java/dev/openrs2/cache/Store.kt

@ -1,6 +1,7 @@
package dev.openrs2.cache package dev.openrs2.cache
import io.netty.buffer.ByteBuf import io.netty.buffer.ByteBuf
import io.netty.buffer.ByteBufAllocator
import java.io.Closeable import java.io.Closeable
import java.io.FileNotFoundException import java.io.FileNotFoundException
import java.io.Flushable import java.io.Flushable
@ -125,13 +126,15 @@ public interface Store : Flushable, Closeable {
* Opens a [Store], automatically detecting the type based on the * Opens a [Store], automatically detecting the type based on the
* presence or absence of the `main_file_cache.dat2` file. * presence or absence of the `main_file_cache.dat2` file.
* @param root the store's root directory. * @param root the store's root directory.
* @param alloc the [ByteBufAllocator] used to allocate buffers for
* groups read from the [Store] and for temporary internal use.
* @throws IOException if an underlying I/O error occurs. * @throws IOException if an underlying I/O error occurs.
*/ */
public fun open(root: Path): Store { public fun open(root: Path, alloc: ByteBufAllocator = ByteBufAllocator.DEFAULT): Store {
return if (Files.isRegularFile(DiskStore.dataPath(root))) { return if (Files.isRegularFile(DiskStore.dataPath(root))) {
DiskStore.open(root) DiskStore.open(root, alloc)
} else { } else {
FlatFileStore.open(root) FlatFileStore.open(root, alloc)
} }
} }
} }

Loading…
Cancel
Save