< prev index next >

src/jdk.jpackage/share/classes/jdk/jpackage/internal/ApplicationLayout.java

Print this page




  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package jdk.jpackage.internal;
  26 
  27 import java.nio.file.Path;
  28 import java.util.Map;
  29 
  30 
  31 /**
  32  * Application directory layout.
  33  */
  34 final class ApplicationLayout implements PathGroup.Facade<ApplicationLayout> {
  35     enum PathRole {
  36         RUNTIME, APP, LAUNCHERS_DIR, DESKTOP
  37     }
  38 
  39     ApplicationLayout(Map<Object, Path> paths) {
  40         data = new PathGroup(paths);
  41     }
  42 
  43     private ApplicationLayout(PathGroup data) {
  44         this.data = data;
  45     }
  46 
  47     @Override
  48     public PathGroup pathGroup() {
  49         return data;
  50     }
  51 
  52     @Override
  53     public ApplicationLayout resolveAt(Path root) {
  54         return new ApplicationLayout(pathGroup().resolveAt(root));
  55     }
  56 
  57     /**
  58      * Path to launchers directory.
  59      */
  60     Path launchersDirectory() {
  61         return pathGroup().getPath(PathRole.LAUNCHERS_DIR);







  62     }
  63 
  64     /**
  65      * Path to application data directory.
  66      */
  67     Path appDirectory() {
  68         return pathGroup().getPath(PathRole.APP);
  69     }
  70 
  71     /**
  72      * Path to Java runtime directory.
  73      */
  74     Path runtimeDirectory() {
  75         return pathGroup().getPath(PathRole.RUNTIME);
  76     }
  77 
  78     /**







  79      * Path to directory with application's desktop integration files.
  80      */
  81     Path destktopIntegrationDirectory() {
  82         return pathGroup().getPath(PathRole.DESKTOP);
  83     }
  84 
  85     static ApplicationLayout unixApp() {
  86         return new ApplicationLayout(Map.of(
  87                 PathRole.LAUNCHERS_DIR, Path.of("bin"),
  88                 PathRole.APP, Path.of("app"),
  89                 PathRole.RUNTIME, Path.of("runtime"),
  90                 PathRole.DESKTOP, Path.of("bin")


  91         ));
  92     }
  93 
  94     static ApplicationLayout windowsApp() {
  95         return new ApplicationLayout(Map.of(
  96                 PathRole.LAUNCHERS_DIR, Path.of(""),
  97                 PathRole.APP, Path.of("app"),
  98                 PathRole.RUNTIME, Path.of("runtime"),
  99                 PathRole.DESKTOP, Path.of("")
 100         ));
 101     }
 102 
 103     static ApplicationLayout platformApp() {
 104         if (Platform.getPlatform() == Platform.WINDOWS) {
 105             return windowsApp();
 106         }
 107 
 108         return unixApp();
 109     }
 110 
 111     static ApplicationLayout javaRuntime() {
 112         return new ApplicationLayout(Map.of(PathRole.RUNTIME, Path.of("")));
 113     }
 114 
 115     private final PathGroup data;
 116 }


  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package jdk.jpackage.internal;
  26 
  27 import java.nio.file.Path;
  28 import java.util.Map;
  29 
  30 
  31 /**
  32  * Application directory layout.
  33  */
  34 final class ApplicationLayout implements PathGroup.Facade<ApplicationLayout> {
  35     enum PathRole {
  36         RUNTIME, APP, LAUNCHERS, DESKTOP, APP_MODS, DLLS
  37     }
  38 
  39     ApplicationLayout(Map<Object, Path> paths) {
  40         data = new PathGroup(paths);
  41     }
  42 
  43     private ApplicationLayout(PathGroup data) {
  44         this.data = data;
  45     }
  46 
  47     @Override
  48     public PathGroup pathGroup() {
  49         return data;
  50     }
  51 
  52     @Override
  53     public ApplicationLayout resolveAt(Path root) {
  54         return new ApplicationLayout(pathGroup().resolveAt(root));
  55     }
  56 
  57     /**
  58      * Path to launchers directory.
  59      */
  60     Path launchersDirectory() {
  61         return pathGroup().getPath(PathRole.LAUNCHERS);
  62     }
  63 
  64     /**
  65      * Path to directory with dynamic libraries.
  66      */
  67     Path dllDirectory() {
  68         return pathGroup().getPath(PathRole.DLLS);
  69     }
  70 
  71     /**
  72      * Path to application data directory.
  73      */
  74     Path appDirectory() {
  75         return pathGroup().getPath(PathRole.APP);
  76     }
  77 
  78     /**
  79      * Path to Java runtime directory.
  80      */
  81     Path runtimeDirectory() {
  82         return pathGroup().getPath(PathRole.RUNTIME);
  83     }
  84 
  85     /**
  86      * Path to application mods directory.
  87      */
  88     Path appModsDirectory() {
  89         return pathGroup().getPath(PathRole.APP_MODS);
  90     }
  91 
  92     /**
  93      * Path to directory with application's desktop integration files.
  94      */
  95     Path destktopIntegrationDirectory() {
  96         return pathGroup().getPath(PathRole.DESKTOP);
  97     }
  98 
  99     static ApplicationLayout linuxApp() {
 100         return new ApplicationLayout(Map.of(
 101                 PathRole.LAUNCHERS, Path.of("bin"),
 102                 PathRole.APP, Path.of("lib/app"),
 103                 PathRole.RUNTIME, Path.of("lib/runtime"),
 104                 PathRole.DESKTOP, Path.of("lib"),
 105                 PathRole.DLLS, Path.of("lib"),
 106                 PathRole.APP_MODS, Path.of("lib/app/mods")
 107         ));
 108     }
 109 
 110     static ApplicationLayout windowsApp() {
 111         return new ApplicationLayout(Map.of(
 112                 PathRole.LAUNCHERS, Path.of(""),
 113                 PathRole.APP, Path.of("app"),
 114                 PathRole.RUNTIME, Path.of("runtime"),
 115                 PathRole.DESKTOP, Path.of("")
 116         ));
 117     }
 118 
 119     static ApplicationLayout platformApp() {
 120         if (Platform.getPlatform() == Platform.WINDOWS) {
 121             return windowsApp();
 122         }
 123 
 124         return linuxApp();
 125     }
 126 
 127     static ApplicationLayout javaRuntime() {
 128         return new ApplicationLayout(Map.of(PathRole.RUNTIME, Path.of("")));
 129     }
 130 
 131     private final PathGroup data;
 132 }
< prev index next >