Class FileManager

java.lang.Object
io.github.jbastgen.stemma.app.io.FileManager

public final class FileManager extends Object
Shows a repository, a folder or a file in the system's file manager (Explorer, Finder, the Files application of the Linux desktop).

The platform's own command is tried first (explorer /select,…, open -R, xdg-open): it can select the file, and it does not need AWT, which shares the main thread with JavaFX on macOS. If that command is missing or fails, java.awt.Desktop is asked. A command from the settings replaces both and is never replaced by something else when it fails. Commands run without a shell, so file names with spaces or quotes are safe.

  • Method Details

    • target

      public static FileManager.Target target(Path repo, String relPath)
      The path to show for a file of the repository. A file that exists is selected; a file that is not there (deleted, or from an old commit) shows its nearest folder that is; no file, or a path that leaves the repository, shows the repository itself.
      Parameters:
      relPath - the path inside the repository with / as separator, or null / empty for the repository
    • command

      public static List<String> command(FileManager.Os os, FileManager.Target target, String override)
      The command that shows the target. A non-blank override (from the settings) is used instead of the platform's command; in it $DIR is the folder to show (the file's folder for a file) and $FILE the file to select (the folder itself when a folder is shown). ${DIR} and ${FILE} work too.
    • show

      public static FileManager.Result show(FileManager.Os os, Path repo, String relPath, String override, FileManager.Runner runner, FileManager.Fallback fallback)
      Shows the file (or the repository) in the file manager. Blocks for at most a few seconds: call it off the UI thread.
      Parameters:
      relPath - the file inside the repository, or null for the repository's folder
      override - the command line of the settings, or empty for the platform's way
    • show

      public static FileManager.Result show(Path repo, String relPath, String override)
      Shows the file (or the repository) with the real system: the platform's command, then java.awt.Desktop.