private boolean readInProgress;
DefaultAsyncFile(final VertxInternal vertx, final String path, String perms, final boolean read, final boolean write, final boolean createNew,
final boolean flush, final DefaultContext context) {
if (!read && !write) {
throw new FileSystemException("Cannot open file for neither reading nor writing");
}
this.vertx = vertx;
Path file = Paths.get(path);
HashSet<OpenOption> options = new HashSet<>();
if (read) options.add(StandardOpenOption.READ);
if (write) options.add(StandardOpenOption.WRITE);
if (createNew) options.add(StandardOpenOption.CREATE);
if (flush) options.add(StandardOpenOption.DSYNC);
try {
if (perms != null) {
FileAttribute<?> attrs = PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString(perms));
ch = AsynchronousFileChannel.open(file, options, vertx.getBackgroundPool(), attrs);
} else {
ch = AsynchronousFileChannel.open(file, options, vertx.getBackgroundPool());
}
} catch (IOException e) {
throw new FileSystemException(e);
}
this.context = context;
}