|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.kde.koala.KStandardDirs
public class KStandardDirs
This is one of the most central classes in kdelibs as it provides a basic service: It knows where the files reside on the user's hard disk. And it's meant to be the only one that knows -- to make the real location as transparent as possible to both the user and the applications. To this end it insulates the application from all information and applications always refer to a file with a resource type (e.g. icon) and a filename (e.g. khexdit.xpm). In an ideal world the application would make no assumption where this file is and leave it up to KStandardDirs.findResource("apps", "Home.desktop") to apply this knowledge to return /opt/kde/share/applnk/Home.desktop or .locate("data", "kgame/background.jpg") to return /opt/kde/share/apps/kgame/background.jpg The main idea behind KStandardDirs is that there are several toplevel prefixes below which the files lie. One of these prefixes is the one where the user installed kdelibs, one is where the application was installed, and one is $HOME/.kde, but there may be even more. Under these prefixes there are several well defined suffixes where specific resource types are to be found. For example, for the resource type "html" the suffixes could be share/doc/HTML and share/doc/kde/HTML. So the search algorithm basically appends to each prefix each registered suffix and tries to locate the file there. To make the thing even more complex, it's also possible to register absolute paths that KStandardDirs looks up after not finding anything in the former steps. They can be useful if the user wants to provide specific directories that aren't in his $HOME/.kde directory for, for example, icons.
KGlobalSettings
Constructor Summary | |
---|---|
|
KStandardDirs()
KStandardDirs' constructor. |
protected |
KStandardDirs(java.lang.Class dummy)
|
Method Summary | |
---|---|
boolean |
addCustomized(KConfig config)
Reads customized entries out of the given config object and add them via addResourceDirs(). |
void |
addKDEDefaults()
This function adds the defaults that are used by the current KDE version. |
void |
addPrefix(java.lang.String dir)
Adds another search dir to front of the fsstnd list. |
boolean |
addResourceDir(java.lang.String type,
java.lang.String absdir)
Adds absolute path at the end of the search path for particular types (for example in case of icons where the user specifies extra paths). |
boolean |
addResourceType(java.lang.String type,
java.lang.String relativename)
Adds suffixes for types. |
void |
addXdgConfigPrefix(java.lang.String dir)
Adds another search dir to front of the XDG_CONFIG_XXX list of prefixes. |
void |
addXdgDataPrefix(java.lang.String dir)
Adds another search dir to front of the XDG_DATA_XXX list of prefixes. |
java.util.ArrayList |
allTypes()
This function will return a list of all the types that KStandardDirs supports. |
int |
calcResourceHash(java.lang.String type,
java.lang.String filename,
boolean deep)
Returns a number that identifies this version of the resource. |
void |
dispose()
Delete the wrapped C++ instance ahead of finalize() |
static boolean |
exists(java.lang.String fullPath)
Checks for existence and accessability of a file or directory. |
protected void |
finalize()
Deletes the wrapped C++ instance |
static int |
findAllExe(java.lang.String[] list,
java.lang.String appname)
|
static int |
findAllExe(java.lang.String[] list,
java.lang.String appname,
java.lang.String pathstr)
|
static int |
findAllExe(java.lang.String[] list,
java.lang.String appname,
java.lang.String pathstr,
boolean ignoreExecBit)
Finds all occurrences of an executable in the system path. |
java.util.ArrayList |
findAllResources(java.lang.String type)
|
java.util.ArrayList |
findAllResources(java.lang.String type,
java.lang.String filter)
|
java.util.ArrayList |
findAllResources(java.lang.String type,
java.lang.String filter,
boolean recursive)
|
java.util.ArrayList |
findAllResources(java.lang.String type,
java.lang.String filter,
boolean recursive,
boolean unique)
Tries to find all resources with the specified type. |
java.util.ArrayList |
findAllResources(java.lang.String type,
java.lang.String filter,
boolean recursive,
boolean unique,
java.lang.String[] relPaths)
Tries to find all resources with the specified type. |
java.util.ArrayList |
findDirs(java.lang.String type,
java.lang.String reldir)
Tries to find all directories whose names consist of the specified type and a relative path. |
static java.lang.String |
findExe(java.lang.String appname)
|
static java.lang.String |
findExe(java.lang.String appname,
java.lang.String pathstr)
|
static java.lang.String |
findExe(java.lang.String appname,
java.lang.String pathstr,
boolean ignoreExecBit)
Finds the executable in the system path. |
java.lang.String |
findResource(java.lang.String type,
java.lang.String filename)
Tries to find a resource in the following order: All PREFIX/\ |
java.lang.String |
findResourceDir(java.lang.String type,
java.lang.String filename)
Tries to find the directory the file is in. |
boolean |
isDisposed()
Has the wrapped C++ instance been deleted? |
boolean |
isRestrictedResource(java.lang.String type)
|
boolean |
isRestrictedResource(java.lang.String type,
java.lang.String relPath)
Checks whether a resource is restricted as part of the KIOSK framework. |
static java.lang.String |
kde_default(java.lang.String type)
This returns a default relative path for the standard KDE resource types. |
static java.lang.String |
kfsstnd_defaultbindir()
Returns the default bin directory in which KDE executables are stored. |
static java.lang.String |
kfsstnd_defaultprefix()
Returns the default toplevel directory where KDE is installed. |
java.lang.String |
kfsstnd_prefixes()
|
java.lang.String |
kfsstnd_xdg_conf_prefixes()
|
java.lang.String |
kfsstnd_xdg_data_prefixes()
|
java.lang.String |
localkdedir()
Returns the toplevel directory in which KStandardDirs will store things. |
java.lang.String |
localxdgconfdir()
|
java.lang.String |
localxdgdatadir()
|
static boolean |
makeDir(java.lang.String dir)
|
static boolean |
makeDir(java.lang.String dir,
int mode)
Recursively creates still-missing directories in the given path. |
static java.lang.String |
realFilePath(java.lang.String filename)
Expands all symbolic links and resolves references to '/./', '/../' and extra '/' characters in filename
and returns the canonicalized absolute pathname. |
static java.lang.String |
realPath(java.lang.String dirname)
Expands all symbolic links and resolves references to '/./', '/../' and extra '/' characters in dirname
and returns the canonicalized absolute pathname. |
java.lang.String |
relativeLocation(java.lang.String type,
java.lang.String absPath)
Converts an absolute path to a path relative to a certain resource. |
java.util.ArrayList |
resourceDirs(java.lang.String type)
This function is used internally by almost all other function as it serves and fills the directories cache. |
java.lang.String |
saveLocation(java.lang.String type)
|
java.lang.String |
saveLocation(java.lang.String type,
java.lang.String suffix)
|
java.lang.String |
saveLocation(java.lang.String type,
java.lang.String suffix,
boolean create)
Finds a location to save files into for the given type in the user's home directory. |
static java.util.ArrayList |
systemPaths()
|
static java.util.ArrayList |
systemPaths(java.lang.String pstr)
Returns an ArrayList list of pathnames in the system path. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected KStandardDirs(java.lang.Class dummy)
public KStandardDirs()
Method Detail |
---|
public void addPrefix(java.lang.String dir)
fsstnd
list.
dir
- The directory to append relative paths to.public void addXdgConfigPrefix(java.lang.String dir)
dir
- The directory to append relative paths to.public void addXdgDataPrefix(java.lang.String dir)
dir
- The directory to append relative paths to.public boolean addResourceType(java.lang.String type, java.lang.String relativename)
type
- Specifies a short descriptive string to access
files of this type.relativename
- Specifies a directory relative to the root
of the KFSSTND.
public boolean addResourceDir(java.lang.String type, java.lang.String absdir)
type
- Specifies a short descriptive string to access files
of this type.absdir
- Points to directory where to look for this specific
type. Non-existant directories may be saved but pruned.
public java.lang.String findResource(java.lang.String type, java.lang.String filename)
type
- The type of the wanted resourcefilename
- A relative filename of the resource.
public boolean isRestrictedResource(java.lang.String type, java.lang.String relPath)
type
- The type of the resource to checkrelPath
- A relative path in the resource.
public boolean isRestrictedResource(java.lang.String type)
public int calcResourceHash(java.lang.String type, java.lang.String filename, boolean deep)
type
- The type of the wanted resourcefilename
- A relative filename of the resource.deep
- If true, all resources are taken into account
otherwise only the one returned by findResource().
public java.util.ArrayList findDirs(java.lang.String type, java.lang.String reldir)
type
- The type of the base directory.reldir
- Relative directory.
public java.lang.String findResourceDir(java.lang.String type, java.lang.String filename)
type
- The type of the wanted resourcefilename
- A relative filename of the resource.
public java.util.ArrayList findAllResources(java.lang.String type, java.lang.String filter, boolean recursive, boolean unique)
type
- The type of resource to locate directories for.filter
- Only accept filenames that fit to filter. The filter
may consist of an optional directory and a QRegExp
wildcard expression. E.g. "images\.jpg". Use null
if you do not want a filter.recursive
- Specifies if the function should decend
into subdirectories.unique
- If specified, only return items which have
unique suffixes - suppressing duplicated filenames.
public java.util.ArrayList findAllResources(java.lang.String type, java.lang.String filter, boolean recursive)
public java.util.ArrayList findAllResources(java.lang.String type, java.lang.String filter)
public java.util.ArrayList findAllResources(java.lang.String type)
public java.util.ArrayList findAllResources(java.lang.String type, java.lang.String filter, boolean recursive, boolean unique, java.lang.String[] relPaths)
type
- The type of resource to locate directories for.filter
- Only accept filenames that fit to filter. The filter
may consist of an optional directory and a QRegExp
wildcard expression. E.g. "images\.jpg". Use null
if you do not want a filter.recursive
- Specifies if the function should decend
into subdirectories.unique
- If specified, only return items which have
unique suffixes.relPaths
- The list to store the relative paths into
These can be used later to .locate() the file
public void addKDEDefaults()
public boolean addCustomized(KConfig config)
config
- The object the entries are read from. This should
contain global config files
config.
public java.util.ArrayList resourceDirs(java.lang.String type)
type
- The type of resource
type.
The function updates the cache if possible. If the resource
type specified is unknown, it will return an empty list.
Note, that the directories are assured to exist beside the save
location, which may not exist, but is returned anyway.public java.util.ArrayList allTypes()
public java.lang.String saveLocation(java.lang.String type, java.lang.String suffix, boolean create)
type
- The type of location to return.suffix
- A subdirectory name.
Makes it easier for you to create subdirectories.
You can't pass filenames here, you _have_ to pass
directory names only and add possible filename in
that directory yourself. A directory name always has a
trailing slash ('/').create
- If set, saveLocation() will create the directories
needed (including those given by suffix
).
public java.lang.String saveLocation(java.lang.String type, java.lang.String suffix)
public java.lang.String saveLocation(java.lang.String type)
public java.lang.String relativeLocation(java.lang.String type, java.lang.String absPath)
type
- The type of resource.absPath
- An absolute path to make relative.
type
that
will find absPath.
If no such relative path exists, absPath
will be returned unchanged.public java.lang.String kfsstnd_prefixes()
public java.lang.String kfsstnd_xdg_conf_prefixes()
public java.lang.String kfsstnd_xdg_data_prefixes()
public java.lang.String localkdedir()
public java.lang.String localxdgdatadir()
public java.lang.String localxdgconfdir()
public static java.util.ArrayList systemPaths(java.lang.String pstr)
pstr
- The path which will be searched. If this is
null (default), the $PATH environment variable will
be searched.
public static java.util.ArrayList systemPaths()
public static java.lang.String findExe(java.lang.String appname, java.lang.String pathstr, boolean ignoreExecBit)
appname
- The name of the executable file for which to search.pathstr
- The path which will be searched. If this is
null (default), the $PATH environment variable will
be searched.ignoreExecBit
- If true, an existing file will be returned
even if its executable bit is not set.
findAllExe(java.lang.String[], java.lang.String, java.lang.String, boolean)
public static java.lang.String findExe(java.lang.String appname, java.lang.String pathstr)
public static java.lang.String findExe(java.lang.String appname)
public static int findAllExe(java.lang.String[] list, java.lang.String appname, java.lang.String pathstr, boolean ignoreExecBit)
list
- Will be filled with the pathnames of all the
executables found. Will be empty if the executable
was not found.appname
- The name of the executable for which to
search.pathstr
- The path list which will be searched. If this
is 0 (default), the $PATH environment variable will
be searched.ignoreExecBit
- If true, an existing file will be returned
even if its executable bit is not set.
findExe(java.lang.String, java.lang.String, boolean)
public static int findAllExe(java.lang.String[] list, java.lang.String appname, java.lang.String pathstr)
public static int findAllExe(java.lang.String[] list, java.lang.String appname)
public static boolean makeDir(java.lang.String dir, int mode)
dir
- Absolute path of the directory to be made.mode
- Directory permissions.
public static boolean makeDir(java.lang.String dir)
public static java.lang.String kde_default(java.lang.String type)
#locate
,
#locateLocal
public static java.lang.String kfsstnd_defaultprefix()
public static java.lang.String kfsstnd_defaultbindir()
public static boolean exists(java.lang.String fullPath)
fullPath
- the path to check. IMPORTANT: must end with a slash if expected to be a directory
(and no slash for a file, obviously).
public static java.lang.String realPath(java.lang.String dirname)
dirname
and returns the canonicalized absolute pathname.
The resulting path will have no symbolic link, '/./'
or '/../' components.
public static java.lang.String realFilePath(java.lang.String filename)
filename
and returns the canonicalized absolute pathname.
The resulting path will have no symbolic link, '/./'
or '/../' components.
protected void finalize() throws java.lang.InternalError
finalize
in class java.lang.Object
java.lang.InternalError
public void dispose()
public boolean isDisposed()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |