create method

Future<UVaultWriter> create(
  1. String path, {
  2. int chunkSize = defaultVaultChunkSize,
})

Opens a writer for a new vault file at path. Supports writes at any offset as long as every chunk is filled by exactly one sequential writer (true for download segments that are aligned to UVaultHeader.chunkSize).

Implementation

Future<UVaultWriter> create(String path, {int chunkSize = defaultVaultChunkSize}) async {
  final (UVaultHeader header, UAead aead) = await newFile(chunkSize: chunkSize);
  final UStorageSink sink = await _backend.open(path, truncate: true);
  await sink.writeAt(0, header.encode());
  return UVaultWriter._(header, aead, sink);
}