--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/ApplicationLayout.java Tue Sep 24 13:41:16 2019 -0400
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.jpackage.internal;
+
+import java.nio.file.Path;
+import java.util.Map;
+
+
+/**
+ * Application directory layout.
+ */
+final class ApplicationLayout implements PathGroup.Facade<ApplicationLayout> {
+ enum PathRole {
+ RUNTIME, APP, LAUNCHERS_DIR, DESKTOP
+ }
+
+ ApplicationLayout(Map<Object, Path> paths) {
+ data = new PathGroup(paths);
+ }
+
+ private ApplicationLayout(PathGroup data) {
+ this.data = data;
+ }
+
+ @Override
+ public PathGroup pathGroup() {
+ return data;
+ }
+
+ @Override
+ public ApplicationLayout resolveAt(Path root) {
+ return new ApplicationLayout(pathGroup().resolveAt(root));
+ }
+
+ /**
+ * Path to launchers directory.
+ */
+ Path launchersDirectory() {
+ return pathGroup().getPath(PathRole.LAUNCHERS_DIR);
+ }
+
+ /**
+ * Path to application data directory.
+ */
+ Path appDirectory() {
+ return pathGroup().getPath(PathRole.APP);
+ }
+
+ /**
+ * Path to Java runtime directory.
+ */
+ Path runtimeDirectory() {
+ return pathGroup().getPath(PathRole.RUNTIME);
+ }
+
+ /**
+ * Path to directory with application's desktop integration files.
+ */
+ Path destktopIntegrationDirectory() {
+ return pathGroup().getPath(PathRole.DESKTOP);
+ }
+
+ static ApplicationLayout unixApp() {
+ return new ApplicationLayout(Map.of(
+ PathRole.LAUNCHERS_DIR, Path.of("bin"),
+ PathRole.APP, Path.of("app"),
+ PathRole.RUNTIME, Path.of("runtime"),
+ PathRole.DESKTOP, Path.of("bin")
+ ));
+ }
+
+ static ApplicationLayout windowsApp() {
+ return new ApplicationLayout(Map.of(
+ PathRole.LAUNCHERS_DIR, Path.of(""),
+ PathRole.APP, Path.of("app"),
+ PathRole.RUNTIME, Path.of("runtime"),
+ PathRole.DESKTOP, Path.of("")
+ ));
+ }
+
+ static ApplicationLayout platformApp() {
+ if (Platform.getPlatform() == Platform.WINDOWS) {
+ return windowsApp();
+ }
+
+ return unixApp();
+ }
+
+ static ApplicationLayout javaRuntime() {
+ return new ApplicationLayout(Map.of(PathRole.RUNTIME, Path.of("")));
+ }
+
+ private final PathGroup data;
+}