openWriteEnsureParent method

Future<IOSink> openWriteEnsureParent({
  1. bool recursive = false,
  2. FileMode mode = FileMode.write,
  3. Encoding encoding = utf8,
})

Opens the file for writing, ensuring that its parent directories are created before opening.

Awaits the creation of the parent directory using recursive. By default, recursive is true to ensure all non-existent parent directories are created. Returns the standard IOSink by calling openWrite with mode and encoding.

Implementation

Future<IOSink> openWriteEnsureParent({
  bool recursive = false,
  FileMode mode = FileMode.write,
  Encoding encoding = utf8,
}) async {
  await parent.create(recursive: recursive);
  return openWrite(mode: mode, encoding: encoding);
}