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 java
.io
.IOException
;
13 import java
.io
.InputStream
;
14 import java
.nio
.file
.Files
;
15 import java
.nio
.file
.Path
;
16 import java
.nio
.file
.StandardOpenOption
;
19 * Jar Library for SummerCoat.
23 public class SummerCoatJarLibrary
24 implements VMClassLibrary
26 /** Special name for SummerCoat ROM chunk. */
27 public static final String ROM_CHUNK_RESOURCE
=
28 "$$SQUIRRELJME$SUMMERCOAT$$";
30 /** The path to the ROM. */
31 protected final Path path
;
34 * Initializes the ROM library.
36 * @param __path The ROM path.
37 * @throws NullPointerException On null arguments.
40 public SummerCoatJarLibrary(Path __path
)
41 throws NullPointerException
44 throw new NullPointerException("NARG");
54 public String
[] listResources()
56 // There is only ever a single resource
57 return new String
[]{SummerCoatJarLibrary
.ROM_CHUNK_RESOURCE
};
67 return this.path
.getFileName().toString();
85 public InputStream
resourceAsStream(String __rc
)
86 throws IOException
, NullPointerException
89 throw new NullPointerException("NARG");
92 if (!SummerCoatJarLibrary
.ROM_CHUNK_RESOURCE
.equals(__rc
))
95 return Files
.newInputStream(this.path
, StandardOpenOption
.READ
);
103 public String
toString()
109 * Checks if this is a SQC or not.
111 * @param __s The file name.
112 * @return If this is a SQC ROM.
113 * @throws NullPointerException On null arguments.
116 public static boolean isSqc(Path __s
)
117 throws NullPointerException
120 throw new NullPointerException("NARG");
122 return SummerCoatJarLibrary
.isSqc(__s
.toString());
126 * Checks if this is a SQC or not.
128 * @param __s The file name.
129 * @return If this is a SQC ROM.
130 * @throws NullPointerException On null arguments.
133 public static boolean isSqc(String __s
)
134 throws NullPointerException
137 throw new NullPointerException("NARG");
139 return __s
.endsWith(".sqc") || __s
.endsWith(".SQC");