open static method
Implementation
static Future<AsyncFile> open(
String path, {
FileOptions options = const FileOptions(),
}) async {
final BytesFile backend;
try {
backend = await openBackend(path, options);
} catch (error, stack) {
Error.throwWithStackTrace(
BlitIOException('failed to open $path', path: path, cause: error),
stack,
);
}
final file = AsyncFile._(path, backend, options);
if (options.truncate && options.writable) {
try {
await backend.truncate(0);
} catch (_) {
await backend.close();
rethrow;
}
}
return file;
}