1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the GNU General Public License v3+, or later.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 package cc
.squirreljme
.vm
;
12 import cc
.squirreljme
.runtime
.cldc
.annotation
.Exported
;
13 import java
.io
.IOException
;
14 import java
.io
.InputStream
;
15 import java
.nio
.file
.Files
;
16 import java
.nio
.file
.Path
;
17 import java
.nio
.file
.StandardOpenOption
;
20 * Jar Library for SummerCoat.
25 public class SummerCoatJarLibrary
26 implements VMClassLibrary
28 /** Special name for SummerCoat ROM chunk. */
29 public static final String ROM_CHUNK_RESOURCE
=
30 "$$SQUIRRELJME$SUMMERCOAT$$";
32 /** The path to the ROM. */
33 protected final Path path
;
36 * Initializes the ROM library.
38 * @param __path The ROM path.
39 * @throws NullPointerException On null arguments.
43 public SummerCoatJarLibrary(Path __path
)
44 throws NullPointerException
47 throw new NullPointerException("NARG");
57 public String
[] listResources()
59 // There is only ever a single resource
60 return new String
[]{SummerCoatJarLibrary
.ROM_CHUNK_RESOURCE
};
70 return this.path
.getFileName().toString();
88 public InputStream
resourceAsStream(String __rc
)
89 throws IOException
, NullPointerException
92 throw new NullPointerException("NARG");
95 if (!SummerCoatJarLibrary
.ROM_CHUNK_RESOURCE
.equals(__rc
))
98 return Files
.newInputStream(this.path
, StandardOpenOption
.READ
);
106 public String
toString()
112 * Checks if this is a SQC or not.
114 * @param __s The file name.
115 * @return If this is a SQC ROM.
116 * @throws NullPointerException On null arguments.
120 public static boolean isSqc(Path __s
)
121 throws NullPointerException
124 throw new NullPointerException("NARG");
126 return SummerCoatJarLibrary
.isSqc(__s
.toString());
130 * Checks if this is a SQC or not.
132 * @param __s The file name.
133 * @return If this is a SQC ROM.
134 * @throws NullPointerException On null arguments.
138 public static boolean isSqc(String __s
)
139 throws NullPointerException
142 throw new NullPointerException("NARG");
144 return __s
.endsWith(".sqc") || __s
.endsWith(".SQC");