diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index 492b484..7108775 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -1,4 +1,5 @@ import org.cryptomator.integrations.mount.MountService; +import org.cryptomator.integrations.revealpath.RevealPathService; import org.cryptomator.integrations.tray.TrayMenuController; import org.cryptomator.integrations.autostart.AutoStartProvider; import org.cryptomator.integrations.keychain.KeychainAccessProvider; @@ -14,12 +15,14 @@ exports org.cryptomator.integrations.common; exports org.cryptomator.integrations.keychain; exports org.cryptomator.integrations.mount; + exports org.cryptomator.integrations.revealpath; exports org.cryptomator.integrations.tray; exports org.cryptomator.integrations.uiappearance; uses AutoStartProvider; uses KeychainAccessProvider; uses MountService; + uses RevealPathService; uses TrayIntegrationProvider; uses TrayMenuController; uses UiAppearanceProvider; diff --git a/src/main/java/org/cryptomator/integrations/revealpath/RevealFailedException.java b/src/main/java/org/cryptomator/integrations/revealpath/RevealFailedException.java new file mode 100644 index 0000000..c56b6f9 --- /dev/null +++ b/src/main/java/org/cryptomator/integrations/revealpath/RevealFailedException.java @@ -0,0 +1,17 @@ +package org.cryptomator.integrations.revealpath; + +public class RevealFailedException extends Exception { + + public RevealFailedException(String msg) { + super(msg); + } + + public RevealFailedException(Exception cause) { + super(cause); + } + + public RevealFailedException(String msg, Exception cause) { + super(msg, cause); + } + +} diff --git a/src/main/java/org/cryptomator/integrations/revealpath/RevealPathService.java b/src/main/java/org/cryptomator/integrations/revealpath/RevealPathService.java new file mode 100644 index 0000000..db7442e --- /dev/null +++ b/src/main/java/org/cryptomator/integrations/revealpath/RevealPathService.java @@ -0,0 +1,38 @@ +package org.cryptomator.integrations.revealpath; + +import org.cryptomator.integrations.common.IntegrationsLoader; + +import java.nio.file.Path; +import java.util.stream.Stream; + +public interface RevealPathService { + + /** + * Loads all supported service providers. + * + * @return Stream of supported RevealPathService implementations (may be empty) + */ + static Stream get() { + return IntegrationsLoader.loadAll(RevealPathService.class).filter(RevealPathService::isSupported); + } + + /** + * Reveal the path in the system default file manager. + *

+ * If the path points to a file, the parent of the file is opened and the file is selected in the file manager window. + * If the path points to a directory, the directory is opened and its content shown in the file manager window. + * + * @param p Path to reveal + * @throws RevealFailedException if revealing the path failed + */ + void reveal(Path p) throws RevealFailedException; + + /** + * Indicates, if this provider can be used. + * + * @return true, if this provider is supported in the current OS environment + * @implSpec This check needs to return fast and in constant time + */ + boolean isSupported(); + +}