|
|
@ -31,11 +31,11 @@ public class DiskStore private constructor( |
|
|
|
private val musicData: BufferedFileChannel?, |
|
|
|
private val musicData: BufferedFileChannel?, |
|
|
|
private val indexes: Array<BufferedFileChannel?>, |
|
|
|
private val indexes: Array<BufferedFileChannel?>, |
|
|
|
private val alloc: ByteBufAllocator, |
|
|
|
private val alloc: ByteBufAllocator, |
|
|
|
legacyData: Boolean |
|
|
|
public val legacy: Boolean |
|
|
|
) : Store { |
|
|
|
) : Store { |
|
|
|
private data class IndexEntry(val size: Int, val block: Int) |
|
|
|
private data class IndexEntry(val size: Int, val block: Int) |
|
|
|
|
|
|
|
|
|
|
|
private val archiveOffset = if (legacyData) 1 else 0 |
|
|
|
private val archiveOffset = if (legacy) 1 else 0 |
|
|
|
|
|
|
|
|
|
|
|
init { |
|
|
|
init { |
|
|
|
require(indexes.size == Store.MAX_ARCHIVE + 1) |
|
|
|
require(indexes.size == Store.MAX_ARCHIVE + 1) |
|
|
@ -505,9 +505,9 @@ public class DiskStore private constructor( |
|
|
|
val legacyDataPath = legacyDataPath(root) |
|
|
|
val legacyDataPath = legacyDataPath(root) |
|
|
|
|
|
|
|
|
|
|
|
// We check for js5DataPath first as it takes precedence. |
|
|
|
// We check for js5DataPath first as it takes precedence. |
|
|
|
val legacyDataFile = !Files.exists(js5DataPath) |
|
|
|
val legacy = !Files.exists(js5DataPath) |
|
|
|
|
|
|
|
|
|
|
|
val dataPath = if (legacyDataFile) { |
|
|
|
val dataPath = if (legacy) { |
|
|
|
legacyDataPath |
|
|
|
legacyDataPath |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
js5DataPath |
|
|
|
js5DataPath |
|
|
@ -545,17 +545,17 @@ public class DiskStore private constructor( |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return DiskStore(root, data, musicData, archives, alloc, legacyDataFile) |
|
|
|
return DiskStore(root, data, musicData, archives, alloc, legacy) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public fun create( |
|
|
|
public fun create( |
|
|
|
root: Path, |
|
|
|
root: Path, |
|
|
|
alloc: ByteBufAllocator = ByteBufAllocator.DEFAULT, |
|
|
|
alloc: ByteBufAllocator = ByteBufAllocator.DEFAULT, |
|
|
|
legacyDataFile: Boolean = false |
|
|
|
legacy: Boolean = false |
|
|
|
): Store { |
|
|
|
): Store { |
|
|
|
Files.createDirectories(root) |
|
|
|
Files.createDirectories(root) |
|
|
|
|
|
|
|
|
|
|
|
val dataPath = if (legacyDataFile) { |
|
|
|
val dataPath = if (legacy) { |
|
|
|
legacyDataPath(root) |
|
|
|
legacyDataPath(root) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
dataPath(root) |
|
|
|
dataPath(root) |
|
|
@ -569,7 +569,7 @@ public class DiskStore private constructor( |
|
|
|
|
|
|
|
|
|
|
|
val archives = Array<BufferedFileChannel?>(Store.MAX_ARCHIVE + 1) { null } |
|
|
|
val archives = Array<BufferedFileChannel?>(Store.MAX_ARCHIVE + 1) { null } |
|
|
|
|
|
|
|
|
|
|
|
return DiskStore(root, data, null, archives, alloc, legacyDataFile) |
|
|
|
return DiskStore(root, data, null, archives, alloc, legacy) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|