src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WindowsBundlerParam.java
branchJDK-8200758-branch
changeset 57283 0b0be19f79e4
parent 57256 d7c27451f759
child 57806 91f8eec58086
equal deleted inserted replaced
57282:c9c2c08854f5 57283:0b0be19f79e4
    23  * questions.
    23  * questions.
    24  */
    24  */
    25 
    25 
    26 package jdk.jpackage.internal;
    26 package jdk.jpackage.internal;
    27 
    27 
       
    28 import java.text.MessageFormat;
    28 import java.util.Map;
    29 import java.util.Map;
    29 import java.util.ResourceBundle;
    30 import java.util.ResourceBundle;
    30 import java.util.function.BiFunction;
    31 import java.util.function.BiFunction;
    31 import java.util.function.Function;
    32 import java.util.function.Function;
    32 
    33 
    84             Arguments.CLIOptions.WIN_DIR_CHOOSER.getId(),
    85             Arguments.CLIOptions.WIN_DIR_CHOOSER.getId(),
    85             Boolean.class,
    86             Boolean.class,
    86             params -> Boolean.FALSE,
    87             params -> Boolean.FALSE,
    87             (s, p) -> Boolean.valueOf(s)
    88             (s, p) -> Boolean.valueOf(s)
    88     );
    89     );
       
    90 
       
    91     static final BundlerParamInfo<String> WINDOWS_INSTALL_DIR =
       
    92             new StandardBundlerParam<>(
       
    93             "windows-install-dir",
       
    94             String.class,
       
    95             params -> {
       
    96                  String dir = INSTALL_DIR.fetchFrom(params);
       
    97                  if (dir != null) {
       
    98                      if (dir.contains(":") || dir.contains("..")) {
       
    99                          Log.error(MessageFormat.format(I18N.getString(
       
   100                                 "message.invalid.install.dir"), dir,
       
   101                                 APP_NAME.fetchFrom(params)));
       
   102                      } else {
       
   103                         if (dir.startsWith("\\")) {
       
   104                              dir = dir.substring(1);
       
   105                         }
       
   106                         if (dir.endsWith("\\")) {
       
   107                              dir = dir.substring(0, dir.length() - 1);
       
   108                         }
       
   109                         return dir;
       
   110                      }
       
   111                  }
       
   112                  return APP_NAME.fetchFrom(params); // Default to app name
       
   113              },
       
   114             (s, p) -> s
       
   115     );
    89 }
   116 }