appendFile method

  1. @override
Future<Result<void, FileError>> appendFile(
  1. String path,
  2. String content
)
override

Creates or appends to a file, creating parent directories.

Implementation

@override
Future<Result<void, FileError>> appendFile(
  String path,
  String content,
) async {
  final resolved = _normalize(path);
  _ensureParents(resolved);
  final existing = _files[resolved];
  final bytes = existing?.bytes ?? Uint8List(0);
  final encoded = Uint8List.fromList(utf8.encode(content));
  final appended = Uint8List(bytes.length + encoded.length);
  appended.setAll(0, bytes);
  appended.setAll(bytes.length, encoded);
  _files[resolved] = _MemoryFile(
    appended,
    DateTime.now().millisecondsSinceEpoch,
  );
  return const Ok(null);
}