Interface TinyFdApi


public interface TinyFdApi
API for TinyFD, a cross-platform file selection dialog.

On Linux, TinyFD "allows shell metacharacters in titles, messages, and other input data," meaning that it is vulnerable to command injection. **Treat all user input as untrusted and sanitize it before passing it to TinyFD.**

  • Field Details

  • Method Details

    • openSaveSelector

      Path openSaveSelector(@Nullable @Nullable String title, @Nullable @Nullable String defaultFilePath, String[] filterPatterns, @Nullable @Nullable String filterDescription)
      Open a save file selection prompt. Same as openFileSelector(String, String, String[], String) but says save instead of open.

      On Linux, TinyFD "allows shell metacharacters in titles, messages, and other input data," meaning that it is vulnerable to command injection. **Treat all user input as untrusted and sanitize it before passing it to TinyFD.**

    • openFileSelector

      @Nullable @Nullable Path openFileSelector(@Nullable @Nullable String title, @Nullable @Nullable String defaultFilePath, String[] filterPatterns, @Nullable @Nullable String filterDescription)
      Open a file selection prompt.

      On Linux, TinyFD "allows shell metacharacters in titles, messages, and other input data," meaning that it is vulnerable to command injection. **Treat all user input as untrusted and sanitize it before passing it to TinyFD.**

      Parameters:
      title - the title of the prompt
      defaultFilePath - the path to the default file to select
      filterPatterns - the file extensions to filter by. e.g. new String[]{"*.png", "*.jpg"}
      filterDescription - the description for said filter. e.g. "Images"
      Returns:
      the selected file, or null if the user cancelled.
    • openMultiFileSelector

      Path[] openMultiFileSelector(@Nullable @Nullable String title, @Nullable @Nullable String defaultFilePath, String[] filterPatterns, @Nullable @Nullable String filterDescription)
      Open a multi file selection prompt. Same as openFileSelector(String, String, String[], String) but allows the user to select multiple files.

      On Linux, TinyFD "allows shell metacharacters in titles, messages, and other input data," meaning that it is vulnerable to command injection. **Treat all user input as untrusted and sanitize it before passing it to TinyFD.**

    • openFolderSelector

      Path openFolderSelector(@Nullable @Nullable String title, @Nullable @Nullable String defaultFolderPath)
      Open a folder selection prompt. Same as openFileSelector(String, String, String[], String) but allows the user to select a folder.

      On Linux, TinyFD "allows shell metacharacters in titles, messages, and other input data," meaning that it is vulnerable to command injection. **Treat all user input as untrusted and sanitize it before passing it to TinyFD.**

    • showMessageBox

      boolean showMessageBox(String title, String message, @NotNull @NotNull String dialog, String icon, boolean defaultValue)
      Shows a message box.

      On Linux, TinyFD "allows shell metacharacters in titles, messages, and other input data," meaning that it is vulnerable to command injection. **Treat all user input as untrusted and sanitize it before passing it to TinyFD.**

      Parameters:
      message - the message. may contain \n and \t
      dialog - the type of message box to show.
      One of: OK_DIALOG, OK_CANCEL_DIALOG, YES_NO_DIALOG, YES_NO_CANCEL_DIALOG
      icon - the icon to use.
      One of: QUESTION_ICON, ERROR_ICON, WARNING_ICON, INFO_ICON
      defaultValue - the default value to return if the user closes the dialog without clicking a button
      Returns:
      true if the user clicked the "ok" or "yes" button, false for "cancel" or "no"
    • showNotification

      int showNotification(String title, String message, String icon)
      Shows a notification.

      On Linux, TinyFD "allows shell metacharacters in titles, messages, and other input data," meaning that it is vulnerable to command injection. **Treat all user input as untrusted and sanitize it before passing it to TinyFD.**

      Parameters:
      icon - the icon to use. One of: QUESTION_ICON, ERROR_ICON, WARNING_ICON, INFO_ICON
      Returns:
      0 if the user clicked the "ok" button, 1 for "cancel"