public class ArtisynthPath
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static java.io.File |
convertToLocalSeparators(java.io.File file)
Tries to convert file separation characters in a file to ones
appropriate for the local system.
|
static java.lang.String |
convertToLocalSeparators(java.lang.String pathName)
Tries to convert file separation characters in a path name to ones
appropriate for the local system.
|
static java.lang.String |
convertToUnixSeparators(java.lang.String pathName)
Tries to convert file separation characters in a path name to ones
appropriate for Unix.
|
static java.lang.String |
convertToWindowsSeparators(java.lang.String pathName)
Tries to convert file separation characters in a path name to ones
appropriate for Windows.
|
static FileSearchPath |
createDefaultSearchPath()
Create a default search path consisting of the user's home
directory and the ArtiSynth home directory.
|
static boolean |
filesAreTheSame(java.io.File f1,
java.io.File f2) |
static java.io.File |
findFile(java.lang.String relpath) |
static java.io.File[] |
findFiles(java.lang.String relpath)
Searches for files.
|
static java.io.File[] |
findFilesMatching(java.util.List<java.io.File> dirList,
java.lang.String pattern) |
static java.io.File[] |
findFilesMatching(java.lang.String pattern) |
static java.net.URL |
findResource(java.lang.String relpath) |
static java.net.URL[] |
findResources(java.lang.String relpath)
Searches for resources.
|
static java.io.File |
getCacheDir()
Finds the Artisynth cache directory.
|
static java.io.File |
getConfigFile(java.lang.String relPath)
Finds a file in the user's config directory.
|
static java.io.File |
getConfigFolder()
Returns the user configuration folder.
|
static java.lang.String |
getFileExtension(java.io.File file) |
static java.lang.String |
getHomeDir()
Returns the Artisynth home directory, as specified by the ARTISYNTH_HOME
environment variable.
|
static java.io.File |
getHomeRelativeFile(java.lang.String relpath,
java.lang.String alternate)
Returns a file specified relative to the Artisynth home directory, as
specified by the environment variable ARTISYNTH_HOME.
|
static java.lang.String |
getHomeRelativePath(java.lang.String relpath,
java.lang.String alternate)
Creates a full path from a path specified relative to the Artisynth home
directory, as specified by the environment variable ARTISYNTH_HOME.
|
static java.lang.String |
getRelativeOrAbsolutePath(java.io.File dir,
java.io.File file)
If
file is located beneath the directory dir , return its
relative path with respect to dir . |
static java.net.URL |
getRelativeResource(java.lang.Object refObj,
java.lang.String relpath)
Returns a URL resource specified by a path relative to a given reference
object.
|
static java.net.URL |
getResource(java.lang.String abspath)
Returns a URL resource specified by an absolute path with respect to the
ArtiSynth package hierarchy.
|
static java.io.File |
getRootRelativeFile(java.lang.Object classObj,
java.lang.String relpath)
Returns a File specified relative to the root directory associated
with a class.
|
static java.lang.String |
getRootRelativePath(java.lang.Object classObj,
java.lang.String relpath)
Returns a file path specified relative to the root directory
associated with a class.
|
static java.io.File |
getSrcRelativeFile(java.lang.Object classObj,
java.lang.String relpath)
Returns a File specified relative to the source directory for a specified
class.
|
static java.lang.String |
getSrcRelativePath(java.lang.Object classObj,
java.lang.String relpath)
Returns a complete file path from a path relative to the source directory
for a specified class.
|
static java.io.File |
getTempDir()
Finds the Artisynth temporary directory.
|
static java.io.File |
getUserHomeFolder()
Returns the user's home folder, or
null if this cannot
be found. |
static java.io.File |
getWorkingDir()
Deprecated.
replaced by
getWorkingFolder() |
static java.lang.String |
getWorkingDirPath()
Gets the canonical path name for the working directory.
|
static java.io.File |
getWorkingFolder()
Gets the current working folder.
|
static void |
main(java.lang.String[] args) |
static void |
setConfigFolder(java.io.File dir)
Allows user configuration folder to be explicitly specified.
|
static void |
setWorkingDir(java.io.File dir)
Deprecated.
replaced by
setWorkingFolder(java.io.File) |
static void |
setWorkingFolder(java.io.File dir)
Sets the current working folder.
|
public static java.net.URL getResource(java.lang.String abspath)
The path should be a standard UNIX-style path, with /
as a
file separator and parent directories delimited by ..
. It
may optionally begin with a /
character.
If the source file hierarchy is separate from the class file hierarchy,
then the resource is first sought with respect to the source file
hierarchy. If the requested resource cannot be found with respect to
either a source file hierarchy or the class file hierarchy, then
null
is returned.
abspath
- absolute path for the resource.java.lang.IllegalArgumentException
- if the path is improperly specified.public static java.net.URL getRelativeResource(java.lang.Object refObj, java.lang.String relpath)
The path should be a standard UNIX-style path, with /
as a
file separator and parent directories delimited by ..
. It
should not begin with a /
.
The reference object must be a associated with class contained within the ArtiSynth package hierarchy. If the reference object is itself a Class object, then the associated class is the object itself. The location of the resource within the package hierarchy is given by appending the specified path to the class package path.
If the source file hierarchy is separate from the class file hierarchy,
then the resource is first sought with respect to the source file
hierarchy. If the requested resource cannot be found with respect to
either a source file hierarchy or the class file hierarchy, then
null
is returned.
refObj
- reference object or classrelpath
- resource pathjava.lang.IllegalArgumentException
- if the path is improperly specified.public static java.io.File getTempDir()
getHomeDir()
public static java.io.File getCacheDir()
getTempDir()
public static java.lang.String getHomeDir()
public static java.io.File getUserHomeFolder()
null
if this cannot
be found.null
public static java.io.File getHomeRelativeFile(java.lang.String relpath, java.lang.String alternate)
alternate
is used instead. Any instances of either
the Unix or Windows file separator characters (i.e., '/'
or
'\'
) are mapped to the file separator character for the
current system.relpath
- file path name relative to ARTISYNTH_HOMEalternate
- used if ARTISYNTH_HOME is not setpublic static java.lang.String getRootRelativePath(java.lang.Object classObj, java.lang.String relpath)
artisynth.core.workspace.RootModel
,
and its class file is located in
/users/home/joe/artisynth_core/classes/artisynth/core/modelbasethen the root directory is
/users/home/joe/artisynth_core
The class is determined from classObj
, either directly,
if classObj
is an instance of Class
, or by
calling classObj.getClass()
. The class must be associated
with a package.
If the relative path specified by relpath
is
null
, then the path for the root directory itself is
returned. Within the returned file path, instances of either the Unix or
Windows file separator characters (i.e., '/'
or
'\'
) are mapped to the file separator character for the
current system.
classObj
- object used to determine the classrelpath
- path relative to the root directorypublic static java.io.File getRootRelativeFile(java.lang.Object classObj, java.lang.String relpath)
getRootRelativePath()
; see that method for more information about how the
file path is created.classObj
- object used to determine the classrelpath
- path relative to the root directorypublic static java.lang.String getHomeRelativePath(java.lang.String relpath, java.lang.String alternate)
alternate
is used instead. Any
instances of either the Unix or Windows file separator characters (i.e.,
'/'
or '\'
) are mapped to the file
separator character for the current system.relpath
- file path name relative to ARTISYNTH_HOMEalternate
- used if ARTISYNTH_HOME is not setpublic static java.lang.String getSrcRelativePath(java.lang.Object classObj, java.lang.String relpath)
src
, and if classes are stored in a
separate file hierarchy, the root directory of that must be named
classes
and must be a sibling of src
.
The class is determined from classObj
, either directly,
if classObj
is an instance of Class
, or by
calling classObj.getClass()
. The class must be associated
with a package.
If the relative path specified by relpath
is
null
, then the path for the source directory itself is
returned. Within the returned file path, instances of either the Unix or
Windows file separator characters (i.e., '/'
or
'\'
) are mapped to the file separator character for the
current system.
classObj
- object used to determine the classrelpath
- path relative to class's source directorypublic static java.io.File getSrcRelativeFile(java.lang.Object classObj, java.lang.String relpath)
getSrcRelativePath()
; see that method for more information about how the
file path is created.classObj
- object uses to determine the classrelpath
- path relative to class's source directorypublic static java.net.URL findResource(java.lang.String relpath)
public static java.io.File findFile(java.lang.String relpath)
public static java.io.File[] findFilesMatching(java.util.List<java.io.File> dirList, java.lang.String pattern)
public static java.io.File[] findFiles(java.lang.String relpath)
relpath
- name of the desired file relative to the directories being searched.public static java.io.File[] findFilesMatching(java.lang.String pattern)
public static java.net.URL[] findResources(java.lang.String relpath)
relpath
- name of the desired resource relative to the directories being searched.public static java.io.File getWorkingDir()
getWorkingFolder()
public static java.io.File getWorkingFolder()
public static java.lang.String getWorkingDirPath()
public static FileSearchPath createDefaultSearchPath()
public static void setWorkingDir(java.io.File dir)
setWorkingFolder(java.io.File)
public static void setWorkingFolder(java.io.File dir)
null
is specified,
then the current working folder is set to whatever folder
corresponds to ".".dir
- new working folderjava.lang.IllegalArgumentException
- if dir is not a folderpublic static java.lang.String convertToLocalSeparators(java.lang.String pathName)
'\'
will be converted to
'/'
, and on Windows, '/'
will be converted
to a '\'
.public static java.io.File convertToLocalSeparators(java.io.File file)
'\'
will be converted to
'/'
, and on Windows, '/'
will be converted
to a '\'
.public static java.lang.String convertToUnixSeparators(java.lang.String pathName)
'\'
will be converted to '/'
.public static java.lang.String convertToWindowsSeparators(java.lang.String pathName)
'/'
will be converted to '\'
.public static java.lang.String getRelativeOrAbsolutePath(java.io.File dir, java.io.File file)
file
is located beneath the directory dir
, return its
relative path with respect to dir
. Otherwise, return its absolute
path.dir
- directory whose path is to be checked against file
file
- file whose path is soughtfile
public static java.lang.String getFileExtension(java.io.File file)
public static java.io.File getConfigFile(java.lang.String relPath)
relPath
- file path relative to the config directorypublic static boolean filesAreTheSame(java.io.File f1, java.io.File f2)
public static void setConfigFolder(java.io.File dir)
public static java.io.File getConfigFolder()
null
value indicates that this folder does not exist.public static void main(java.lang.String[] args)