writeAll method

Future<OkfWriteResult> writeAll(
  1. String rootPath,
  2. Map<String, String> files, {
  3. bool checkOnly = false,
})

Writes all files, keyed by bundle-relative path.

When checkOnly is true the filesystem is not changed; the returned paths identify files that would be written.

Implementation

Future<OkfWriteResult> writeAll(
  String rootPath,
  Map<String, String> files, {
  bool checkOnly = false,
}) async {
  if (checkOnly) {
    final root = await _validatedRoot(rootPath, createIfMissing: false);
    return _writeAll(
      root,
      _normalizeFiles(files),
      checkOnly: true,
    );
  }
  await _createRootParent(rootPath);
  return OkfBundleApplyLock.synchronized(rootPath, () async {
    final root = await _validatedRoot(rootPath, createIfMissing: true);
    return _writeAll(
      root,
      _normalizeFiles(files),
      checkOnly: false,
    );
  });
}