10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
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
26 package com.oracle.tools.packager;
27
28 import java.io.File;
29
30 import java.util.LinkedHashSet;
31 import java.util.Set;
32
33 public class RelativeFileSet {
34
35 public static enum Type {
36 UNKNOWN, jnlp, jar, nativelib, icon, license, data
37 }
38
39 private Type type = Type.UNKNOWN;
40 private String mode;
41 private String os;
42 private String arch;
43
44 private File basedir;
45 Set<String> files = new LinkedHashSet<>();
46
47 public RelativeFileSet(File base, Set<File> files) {
48 basedir = base;
49 String baseAbsolute = basedir.getAbsolutePath();
50 for (File f: files) {
51 String absolute = f.getAbsolutePath();
52 if (!absolute.startsWith(baseAbsolute)) {
53 throw new RuntimeException("File " + f.getAbsolutePath() +
54 " does not belong to "+baseAbsolute);
55 }
56 if (!absolute.equals(baseAbsolute)) { //possible in javapackager case
57 this.files.add(absolute.substring(baseAbsolute.length()+1));
58 }
59 }
60 }
61
62 public boolean contains(String[] requiredFiles) {
63 boolean result = true;
64
65 for(String fname: requiredFiles) {
66 if (!files.contains(fname)) {
67 Log.debug(" Runtime does not contain [" + fname + "]");
68 result = false;
69 }
70 }
71
72 return result;
73 }
74
75 public boolean contains(String requiredFile) {
76 if (files.contains(requiredFile)) {
77 return true;
78 } else {
79 Log.debug(" Runtime does not contain [" + requiredFile + "]");
80 return false;
81 }
|
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
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
26 package com.oracle.tools.packager;
27
28 import java.io.File;
29
30 import java.util.Collection;
31 import java.util.LinkedHashSet;
32 import java.util.Set;
33
34 public class RelativeFileSet {
35
36 public static enum Type {
37 UNKNOWN, jnlp, jar, nativelib, icon, license, data
38 }
39
40 private Type type = Type.UNKNOWN;
41 private String mode;
42 private String os;
43 private String arch;
44
45 private File basedir;
46 Set<String> files = new LinkedHashSet<>();
47
48 public RelativeFileSet(File base, Collection<File> files) {
49 basedir = base;
50 String baseAbsolute = basedir.getAbsolutePath();
51 for (File f: files) {
52 String absolute = f.getAbsolutePath();
53 if (!absolute.startsWith(baseAbsolute)) {
54 throw new RuntimeException("File " + f.getAbsolutePath() +
55 " does not belong to "+baseAbsolute);
56 }
57 if (!absolute.equals(baseAbsolute)) { //possible in javapackager case
58 this.files.add(absolute.substring(baseAbsolute.length()+1));
59 }
60 }
61 }
62
63 public RelativeFileSet(File base, Set<File> files) {
64 this(base, (Collection<File>) files);
65 }
66
67 public boolean contains(String[] requiredFiles) {
68 boolean result = true;
69
70 for(String fname: requiredFiles) {
71 if (!files.contains(fname)) {
72 Log.debug(" Runtime does not contain [" + fname + "]");
73 result = false;
74 }
75 }
76
77 return result;
78 }
79
80 public boolean contains(String requiredFile) {
81 if (files.contains(requiredFile)) {
82 return true;
83 } else {
84 Log.debug(" Runtime does not contain [" + requiredFile + "]");
85 return false;
86 }
|