public final class UtilityMedia extends Object
HDD
, JAR
...
Example:
Engine.start("First Code", Version.create(1, 0, 0), "resources"); final Media media = Media.get("img", "image.png"); System.out.println(media.getPath()); // print: resources/img/image.png
Modifier and Type | Field and Description |
---|---|
static String |
WORKING_DIR
Engine working directory.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
checkExist(Media media)
Check if the media exists.
|
static boolean |
createPath(String source,
String... path)
Create a full path and each directory.
|
static void |
exist(Media media)
Check if the media exists.
|
static Media |
get(File file)
Get a media from an existing file descriptor.
|
static Media |
get(String... path)
Get a media from its path (start by default in the resources directory).
|
static File |
getFile(String outfile,
InputStream stream)
Copy stream into a temporary file and return this file (localized on current system).
|
static OutputStream |
getOutputStream(Media media,
String from,
boolean logger)
Get output stream of specified path.
|
static String |
getRessourcesDir()
Get current resource directory.
|
static InputStream |
getStream(Media media,
String from)
Get stream of specified path.
|
static InputStream |
getStream(Media media,
String from,
boolean logger)
Get stream of specified path.
|
static File |
getTempFile(Media media,
boolean cache,
boolean mustExist)
Get a temporary file, including cache check.
|
static String |
getWorkingDir()
Get current working directory (execution directory).
|
public static final String WORKING_DIR
public static void exist(Media media)
LionEngineException
if not.media
- The media to test.public static boolean checkExist(Media media)
media
- The media to test.true
if exists, false
else.public static boolean createPath(String source, String... path)
source
- The source directory.path
- The full path.true
if created, false
else.public static Media get(String... path)
Example: Media.get("sprites", "hero.png")
will return resources/sprites/hero.png
. This
function is OS independent !
path
- The list of folders (if has) and file.public static Media get(File file)
file
- The file descriptor.public static InputStream getStream(Media media, String from)
media
- The input media path, pointing to a file.from
- The from function.public static InputStream getStream(Media media, String from, boolean logger)
media
- The input media path, pointing to a file.from
- The from function.logger
- The logger flag.public static OutputStream getOutputStream(Media media, String from, boolean logger)
media
- The input media path, pointing to a file.from
- The from function.logger
- The logger flag.public static File getFile(String outfile, InputStream stream)
outfile
- The file which will store stream.stream
- The input stream.public static File getTempFile(Media media, boolean cache, boolean mustExist)
media
- The original media path (may be inside a JAR).cache
- The cache state (true
will check if file is not already cached).mustExist
- true
if the file must already exist (will throw a LionEngineException
if
not existing), false
else.public static String getWorkingDir()
public static String getRessourcesDir()
Copyright © 2014 Byron 3D Games Studio. All rights reserved.