Class WadUtils
- Author:
- Matthew Tropiano
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
A functional interface that describes a function that takes a Wad and returns void, without handling any exceptions thrown by it.static class
An accumulator for WadEntries.static interface
A functional interface that describes a function that takes a Wad and returns data, without handling any exceptions thrown by it. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
cleanEntries
(Wad source, File destination) Creates a new WAD file by copying the contents of an existing WAD to another file, which discards all un-addressed data from the first.static void
createWadAnd
(File path, WadUtils.WadConsumer wadConsumer) Creates a new WAD file, performs an action on it, and then closes it automatically afterward.static void
createWadAnd
(String path, WadUtils.WadConsumer wadConsumer) Creates a new WAD file, performs an action on it, and then closes it automatically afterward.static WadEntry[]
getEntriesInNamespace
(Wad wad, String prefix) Finds all entries within a WAD entry namespace.static WadEntry[]
getEntriesInNamespace
(Wad wad, String prefix, Pattern ignorePattern) Finds all entries within a WAD entry namespace.static void
openWadAnd
(File path, WadUtils.WadConsumer wadConsumer) Opens a WAD file, performs an action on it, and then closes it automatically afterward.static void
openWadAnd
(String path, WadUtils.WadConsumer wadConsumer) Opens a WAD file, performs an action on it, and then closes it automatically afterward.static WadBuffer
openWadAndExtractBuffer
(File path, WadUtils.WadFunction<WadEntry[]> wadFunction) Opens a WAD file, exports a list of entries to a new returnedWadBuffer
, and then closes it automatically afterward.static WadBuffer
openWadAndExtractBuffer
(String path, WadUtils.WadFunction<WadEntry[]> wadFunction) Opens a WAD file, exports a list of entries to a new returnedWadBuffer
, and then closes it automatically afterward.static void
openWadAndExtractTo
(File path, File outPath, WadUtils.WadFunction<WadEntry[]> wadFunction) Opens a WAD file, exports a list of entries to a new WAD, and then closes both automatically afterward.static void
openWadAndExtractTo
(File path, String outPath, WadUtils.WadFunction<WadEntry[]> wadFunction) Opens a WAD file, exports a list of entries to a new WAD, and then closes both automatically afterward.static void
openWadAndExtractTo
(String path, File outPath, WadUtils.WadFunction<WadEntry[]> wadFunction) Opens a WAD file, exports a list of entries to a new WAD, and then closes both automatically afterward.static void
openWadAndExtractTo
(String path, String outPath, WadUtils.WadFunction<WadEntry[]> wadFunction) Opens a WAD file, exports a list of entries to a new WAD, and then closes both automatically afterward.static <R> R
openWadAndGet
(File path, WadUtils.WadFunction<R> wadFunction) Opens a WAD file, retrieves information from it (which is returned), and then closes it automatically afterward.static <R> R
openWadAndGet
(String path, WadUtils.WadFunction<R> wadFunction) Opens a WAD file, retrieves information from it, and then closes it automatically afterward.static WadUtils.WadEntryAccumulator
withEntries
(WadEntry... entries) Creates a WadEntry accumulator with a set of entries.
-
Method Details
-
withEntries
Creates a WadEntry accumulator with a set of entries.- Parameters:
entries
- the entries to start the accumulator with.- Returns:
- a new accumulator with the provided entries already added.
- Since:
- 2.5.0
-
cleanEntries
Creates a new WAD file by copying the contents of an existing WAD to another file, which discards all un-addressed data from the first. The source Wad must be an implementation that supports retrieving data from it.- Parameters:
source
- the source Wad.destination
- the destination file.- Throws:
UnsupportedOperationException
- if the provided Wad is not an implementation that you can read data from.SecurityException
- if the target file cannot be written to due to security reasons.IOException
- if a read or write error occurs.
-
getEntriesInNamespace
Finds all entries within a WAD entry namespace. A namespace is marked by one or two characters and "_START" or "_END" as a suffix. All entries in between are considered part of the "namespace."The returned entries are valid only to the provided WAD. Using entry information with unassociated WADs could create undesired results.
- Parameters:
prefix
- the namespace prefix to use (e.g. "F" or "FF" for flats, "P" or "PP" for patches, etc.).wad
- the WAD file to scan.- Returns:
- an array of all entries in the namespace, or an empty array if none are found.
-
getEntriesInNamespace
Finds all entries within a WAD entry namespace. A namespace is marked by one or two characters and "_START" or "_END" as a suffix. All entries in between are considered part of the "namespace."The returned entries are valid only to the provided WAD. Using entry information with unassociated WADs could create undesired results.
- Parameters:
prefix
- the namespace prefix to use (e.g. "F" or "FF" for flats, "P" or "PP" for texture patches, etc.).wad
- the WAD file to scan.ignorePattern
- the regex pattern to use for deciding which entries in the namespace to ignore.- Returns:
- an array of all entries in the namespace, or an empty array if none are found.
-
createWadAnd
Creates a new WAD file, performs an action on it, and then closes it automatically afterward. The opened WAD is passed to the providedWadUtils.WadConsumer
.- Parameters:
path
- the path to the WAD file.wadConsumer
- aWadUtils.WadConsumer
that takes the opened Wad as its only parameter.- Throws:
IOException
- if any I/O exception occurs.- Since:
- 2.6.0
-
createWadAnd
Creates a new WAD file, performs an action on it, and then closes it automatically afterward. The opened WAD is passed to the providedWadUtils.WadConsumer
.- Parameters:
path
- the path to the WAD file.wadConsumer
- aWadUtils.WadConsumer
that takes the opened Wad as its only parameter.- Throws:
IOException
- if any I/O exception occurs.- Since:
- 2.6.0
-
openWadAnd
Opens a WAD file, performs an action on it, and then closes it automatically afterward. The opened WAD is passed to the providedWadUtils.WadConsumer
.- Parameters:
path
- the path to the WAD file.wadConsumer
- aWadUtils.WadConsumer
that takes the opened Wad as its only parameter.- Throws:
IOException
- if any I/O exception occurs.- Since:
- 2.5.0
-
openWadAnd
Opens a WAD file, performs an action on it, and then closes it automatically afterward. The opened WAD is passed to the providedWadUtils.WadConsumer
.This method is intended for pure convenience, and will throw a
RuntimeException
if an exception occurs. Do not use this if you intend to handle errors explicitly.- Parameters:
path
- the path to the WAD file.wadConsumer
- aWadUtils.WadConsumer
that takes the opened Wad as its only parameter.- Throws:
IOException
- if any I/O exception occurs.- Since:
- 2.5.0
-
openWadAndGet
public static <R> R openWadAndGet(String path, WadUtils.WadFunction<R> wadFunction) throws IOException Opens a WAD file, retrieves information from it, and then closes it automatically afterward. The opened WAD is passed to the providedWadUtils.WadFunction
.This method is intended for pure convenience, and will throw a
RuntimeException
if an exception occurs. Do not use this if you intend to handle errors explicitly.- Type Parameters:
R
- the return type.- Parameters:
path
- the path to the WAD file.wadFunction
- aWadUtils.WadFunction
that takes the opened Wad as its only parameter.- Returns:
- the data returned from the provided function.
- Throws:
IOException
- if any I/O exception occurs.- Since:
- 2.5.0
-
openWadAndGet
public static <R> R openWadAndGet(File path, WadUtils.WadFunction<R> wadFunction) throws IOException Opens a WAD file, retrieves information from it (which is returned), and then closes it automatically afterward. The opened WAD is passed to the providedWadUtils.WadFunction
.This method is intended for pure convenience, and will throw a
RuntimeException
if an exception occurs. Do not use this if you intend to handle errors explicitly.- Type Parameters:
R
- the return type.- Parameters:
path
- the path to the WAD file.wadFunction
- aWadUtils.WadFunction
that takes the opened Wad as its only parameter.- Returns:
- the data returned from the provided function.
- Throws:
IOException
- if any I/O exception occurs.- Since:
- 2.5.0
-
openWadAndExtractTo
public static void openWadAndExtractTo(String path, String outPath, WadUtils.WadFunction<WadEntry[]> wadFunction) throws IOException Opens a WAD file, exports a list of entries to a new WAD, and then closes both automatically afterward. The opened WAD is passed to the providedWadUtils.WadFunction
.This method is intended for pure convenience, and will throw a
RuntimeException
if an exception occurs. Do not use this if you intend to handle errors explicitly.- Parameters:
path
- the path to the WAD file.outPath
- the output path for the new WAD file.wadFunction
- aWadUtils.WadFunction
that takes the opened Wad as its only parameter.- Throws:
IOException
- if any I/O exception occurs.- Since:
- 2.5.0
-
openWadAndExtractTo
public static void openWadAndExtractTo(String path, File outPath, WadUtils.WadFunction<WadEntry[]> wadFunction) throws IOException Opens a WAD file, exports a list of entries to a new WAD, and then closes both automatically afterward. The opened WAD is passed to the providedWadUtils.WadFunction
.This method is intended for pure convenience, and will throw a
RuntimeException
if an exception occurs. Do not use this if you intend to handle errors explicitly.- Parameters:
path
- the path to the WAD file.outPath
- the output path for the new WAD file.wadFunction
- aWadUtils.WadFunction
that takes the opened Wad as its only parameter.- Throws:
IOException
- if any I/O exception occurs.- Since:
- 2.5.0
-
openWadAndExtractTo
public static void openWadAndExtractTo(File path, String outPath, WadUtils.WadFunction<WadEntry[]> wadFunction) throws IOException Opens a WAD file, exports a list of entries to a new WAD, and then closes both automatically afterward. The opened WAD is passed to the providedWadUtils.WadFunction
.This method is intended for pure convenience, and will throw a
RuntimeException
if an exception occurs. Do not use this if you intend to handle errors explicitly.- Parameters:
path
- the path to the WAD file.outPath
- the output path for the new WAD file.wadFunction
- aWadUtils.WadFunction
that takes the opened Wad as its only parameter.- Throws:
IOException
- if any I/O exception occurs.- Since:
- 2.5.0
-
openWadAndExtractTo
public static void openWadAndExtractTo(File path, File outPath, WadUtils.WadFunction<WadEntry[]> wadFunction) throws IOException Opens a WAD file, exports a list of entries to a new WAD, and then closes both automatically afterward. The opened WAD is passed to the providedWadUtils.WadFunction
.This method is intended for pure convenience, and will throw a
RuntimeException
if an exception occurs. Do not use this if you intend to handle errors explicitly.- Parameters:
path
- the path to the WAD file.outPath
- the output path for the new WAD file.wadFunction
- aWadUtils.WadFunction
that takes the opened Wad as its only parameter.- Throws:
IOException
- if any I/O exception occurs.- Since:
- 2.5.0
-
openWadAndExtractBuffer
public static WadBuffer openWadAndExtractBuffer(String path, WadUtils.WadFunction<WadEntry[]> wadFunction) throws IOException Opens a WAD file, exports a list of entries to a new returnedWadBuffer
, and then closes it automatically afterward. The opened WAD is passed to the providedWadUtils.WadFunction
.This method is intended for pure convenience, and will throw a
RuntimeException
if an exception occurs. Do not use this if you intend to handle errors explicitly.- Parameters:
path
- the path to the WAD file.wadFunction
- aWadUtils.WadFunction
that takes the opened Wad as its only parameter.- Returns:
- the WadBuffer with the desired entries.
- Throws:
IOException
- if any I/O exception occurs.- Since:
- 2.5.0
-
openWadAndExtractBuffer
public static WadBuffer openWadAndExtractBuffer(File path, WadUtils.WadFunction<WadEntry[]> wadFunction) throws IOException Opens a WAD file, exports a list of entries to a new returnedWadBuffer
, and then closes it automatically afterward. The opened WAD is passed to the providedWadUtils.WadFunction
.This method is intended for pure convenience, and will throw a
RuntimeException
if an exception occurs. Do not use this if you intend to handle errors explicitly.- Parameters:
path
- the path to the WAD file.wadFunction
- aWadUtils.WadFunction
that takes the opened Wad as its only parameter.- Returns:
- the WadBuffer with the desired entries.
- Throws:
IOException
- if any I/O exception occurs.- Since:
- 2.5.0
-