Example usage for io.vertx.core.file FileSystem mkdir

List of usage examples for io.vertx.core.file FileSystem mkdir

Introduction

In this page you can find the example usage for io.vertx.core.file FileSystem mkdir.

Prototype

Future<Void> mkdir(String path, String perms);

Source Link

Document

Like #mkdir(String,String,Handler) but returns a Future of the asynchronous result

Usage

From source file:org.entcore.directory.pojo.ImportInfos.java

License:Open Source License

private void moveFiles(final List<String> l, final FileSystem fs, final Handler<AsyncResult<String>> handler) {
    final String p = path + File.separator + structureName
            + (isNotEmpty(structureExternalId) ? "@" + structureExternalId : "") + "_"
            + (isNotEmpty(UAI) ? UAI : "") + "_" + (isNotEmpty(overrideClass) ? overrideClass : "");
    fs.mkdir(p, new Handler<AsyncResult<Void>>() {
        @Override/*from w ww .  ja  v a 2  s  .  c o  m*/
        public void handle(AsyncResult<Void> event) {
            if (event.succeeded()) {
                final AtomicInteger count = new AtomicInteger(l.size());
                for (String f : l) {
                    fs.move(f, p + File.separator + f.substring(path.length() + 1),
                            new Handler<AsyncResult<Void>>() {
                                @Override
                                public void handle(AsyncResult<Void> event2) {
                                    if (event2.succeeded()) {
                                        if (count.decrementAndGet() == 0) {
                                            handler.handle(new DefaultAsyncResult<>((String) null));
                                        }
                                    } else {
                                        count.set(-1);
                                        handler.handle(new DefaultAsyncResult<String>(event2.cause()));
                                    }
                                }
                            });
                }
            } else {
                handler.handle(new DefaultAsyncResult<String>(event.cause()));
            }
        }
    });
}