writeFile method

  1. @override
Future<void> writeFile(
  1. String path,
  2. List<int> data
)
override

Writes data to a file at the specified path.

Implementation

@override
Future<void> writeFile(String path, List<int> data) async {
  if (_isDirectChildOfRoot(path)) {
    throw FileSystemException(
        "Cannot create or write file directly in the virtual root", path);
  }
  final fullPath = resolvePath(path);
  if (fullPath == rootDirectory) {
    throw FileSystemException("Cannot write to root directory", path);
  }
  final file = File(fullPath);
  // Ensure parent directory exists before writing
  await file.parent.create(recursive: true);
  await file.writeAsBytes(data);
}