From c5c5f602fc225e0a9f41bf64e11efb3a624e7e8f Mon Sep 17 00:00:00 2001 From: Julien Viet Date: Wed, 5 Mar 2025 14:26:29 +0100 Subject: [PATCH] Deprecate FileSystem recursive deletion that uses a recursive parameter: instead deleteRecursive or delete should be used --- .../java/io/vertx/core/file/FileSystem.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/main/java/io/vertx/core/file/FileSystem.java b/src/main/java/io/vertx/core/file/FileSystem.java index bfb0aa0363c..13422605754 100644 --- a/src/main/java/io/vertx/core/file/FileSystem.java +++ b/src/main/java/io/vertx/core/file/FileSystem.java @@ -413,21 +413,59 @@ public interface FileSystem { * @param recursive delete recursively? * @param handler the handler that will be called on completion * @return a reference to this, so the API can be used fluently + * @deprecated instead use {@link #deleteRecursive(String, Handler)} or {@link #delete(String, Handler)} */ + @Deprecated @Fluent FileSystem deleteRecursive(String path, boolean recursive, Handler> handler); /** * Like {@link #deleteRecursive(String, boolean, Handler)} but returns a {@code Future} of the asynchronous result + * + * @deprecated instead use {@link #deleteRecursive(String)} or {@link #delete(String)} */ + @Deprecated Future deleteRecursive(String path, boolean recursive); /** * Blocking version of {@link #deleteRecursive(String, boolean, Handler)} + * + * @deprecated instead use {@link #deleteRecursiveBlocking(String)} or {@link #deleteBlocking(String)} */ + @Deprecated @Fluent FileSystem deleteRecursiveBlocking(String path, boolean recursive) ; + /** + * Deletes the file represented by the specified {@code path}, asynchronously. + *

+ * If the path represents a directory and {@code recursive = true} then the directory and its contents will be + * deleted recursively. + * + * @param path path to the file + * @param handler the handler that will be called on completion + * @return a reference to this, so the API can be used fluently + */ + @Fluent + default FileSystem deleteRecursive(String path, Handler> handler) { + return deleteRecursive(path, true, handler); + } + + /** + * Like {@link #deleteRecursive(String, Handler)} but returns a {@code Future} of the asynchronous result + */ + default Future deleteRecursive(String path) { + return deleteRecursive(path, true); + } + + /** + * Blocking version of {@link #deleteRecursive(String, Handler)} + */ + @Fluent + default FileSystem deleteRecursiveBlocking(String path) { + return deleteRecursiveBlocking(path, true); + } + /** * Create the directory represented by {@code path}, asynchronously. *