writeAll method
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.
expectedSources maps paths to the text the caller read. A mismatch fails
the call instead of writing or reporting against stale content.
In both modes, an invalid or repeated path, or a text that holds an unpaired surrogate, throws ArgumentError before the filesystem is touched.
Implementation
Future<OkfWriteResult> writeAll(
String rootPath,
Map<String, String> files, {
bool checkOnly = false,
Map<String, String> expectedSources = const <String, String>{},
}) async {
final normalizedFiles = _normalizeFiles(files);
if (checkOnly) {
final root = await _validatedRoot(rootPath, createIfMissing: false);
return _writeAll(root, normalizedFiles, expectedSources, checkOnly: true);
}
await _createRoot(rootPath);
return OkfBundleLock.write(rootPath, () async {
final root = await _validatedRoot(rootPath, createIfMissing: true);
return _writeAll(
root,
normalizedFiles,
expectedSources,
checkOnly: false,
);
});
}