man-pages/man3/File::BaseDir.3pm.html
2021-03-31 01:06:50 +01:00

279 lines
7.1 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of File::BaseDir</TITLE>
</HEAD><BODY>
<H1>File::BaseDir</H1>
Section: User Contributed Perl Documentation (3pm)<BR>Updated: 2018-05-11<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
File::BaseDir - Use the Freedesktop.org base directory specification
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<PRE>
use File::BaseDir qw/xdg_data_files/;
for ( xdg_data_files('mime/globs') ) {
# do something
}
</PRE>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
This module can be used to find directories and files as specified
by the Freedesktop.org Base Directory Specification. This specifications
gives a mechanism to locate directories for configuration, application data
and cache data. It is suggested that desktop applications for e.g. the
Gnome, <FONT SIZE="-1">KDE</FONT> or Xfce platforms follow this layout. However, the same layout can
just as well be used for non-GUI applications.
<P>
This module forked from File::MimeInfo.
<P>
This module follows version 0.6 of BaseDir specification.
<A NAME="lbAE">&nbsp;</A>
<H2>EXPORT</H2>
None by default, but all methods can be exported on demand.
Also the groups ``:lookup'' and ``:vars'' are defined. The ``:vars'' group
contains all routines with a ``xdg_'' prefix; the ``:lookup'' group
contains the routines to locate files and directories.
<A NAME="lbAF">&nbsp;</A>
<H2>METHODS</H2>
<DL COMPACT>
<DT id="1">&quot;new()&quot;<DD>
Simple constructor to allow Object Oriented use of this module.
</DL>
<A NAME="lbAG">&nbsp;</A>
<H3>Lookup</H3>
The following methods are used to lookup files and folders in one of the
search paths.
<DL COMPACT>
<DT id="2">&quot;data_home(@PATH)&quot;<DD>
Takes a list of file path elements and returns a new path by appending
them to the data home directory. The new path does not need to exist.
Use this when writing user specific application data.
<P>
Example:
<P>
<PRE>
# data_home is: /home/USER/.local/share
$path = $bd-&gt;data_home('Foo', 'Bar', 'Baz');
# returns: /home/USER/.local/share/Foo/Bar/Baz
</PRE>
<DT id="3">&quot;data_dirs(@PATH)&quot;<DD>
Looks for directories specified by <TT>@PATH</TT> in the data home and
other data directories. Returns (possibly empty) list of readable
directories. In scalar context only the first directory found is
returned. Use this to lookup application data.
<DT id="4">&quot;data_files(@PATH)&quot;<DD>
Looks for files specified by <TT>@PATH</TT> in the data home and other data
directories. Only returns files that are readable. In scalar context only
the first file found is returned. Use this to lookup application data.
<DT id="5">&quot;config_home(@PATH)&quot;<DD>
Takes a list of path elements and appends them to the config home
directory returning a new path. The new path does not need to exist.
Use this when writing user specific configuration.
<DT id="6">&quot;config_dirs(@PATH)&quot;<DD>
Looks for directories specified by <TT>@PATH</TT> in the config home and
other config directories. Returns (possibly empty) list of readable
directories. In scalar context only the first directory found is
returned. Use this to lookup configuration.
<DT id="7">&quot;config_files(@PATH)&quot;<DD>
Looks for files specified by <TT>@PATH</TT> in the config home and other
config directories. Returns a (possibly empty) list of files that
are readable. In scalar context only the first file found is returned.
Use this to lookup configuration.
<DT id="8">&quot;cache_home(@PATH)&quot;<DD>
Takes a list of path elements and appends them to the cache home
directory returning a new path. The new path does not need to exist.
</DL>
<A NAME="lbAH">&nbsp;</A>
<H3>Variables</H3>
The following methods only returns the value of one of the <FONT SIZE="-1">XDG</FONT> variables.
<DL COMPACT>
<DT id="9">&quot;xdg_data_home&quot;<DD>
Returns either <TT>$ENV{XDG_DATA_HOME}</TT> or it's default value.
Default is <I></I>$HOME<I>/.local/share</I>.
<DT id="10">&quot;xdg_data_dirs&quot;<DD>
Returns either <TT>$ENV{XDG_DATA_DIRS}</TT> or it's default value as list.
Default is <I>/usr/local/share</I>, <I>/usr/share</I>.
<DT id="11">&quot;xdg_config_home&quot;<DD>
Returns either <TT>$ENV{XDG_CONFIG_HOME}</TT> or it's default value.
Default is <I></I>$HOME<I>/.config</I>.
<DT id="12">&quot;xdg_config_dirs&quot;<DD>
Returns either <TT>$ENV{XDG_CONFIG_DIRS}</TT> or it's default value as list.
Default is <I>/etc/xdg</I>.
<DT id="13">&quot;xdg_cache_home&quot;<DD>
Returns either <TT>$ENV{XDG_CACHE_HOME}</TT> or it's default value.
Default is <I></I>$HOME<I>/.cache</I>.
</DL>
<A NAME="lbAI">&nbsp;</A>
<H2>NON-UNIX PLATFORMS</H2>
The use of File::Spec ensures that all paths are returned in the appropriate
form for the current platform. On Windows this module will try to set <TT>$HOME</TT>
to a sensible value if it is not defined yet. On other platforms one can use
e.g. File::HomeDir to set <TT>$HOME</TT> before loading File::BaseDir.
<P>
Please note that the specification is targeting Unix platforms only and
will only have limited relevance on other platforms. Any platform dependent
behavior in this module should be considered an extension of the spec.
<A NAME="lbAJ">&nbsp;</A>
<H2>BACKWARDS COMPATIBILITY</H2>
The methods <TT>&quot;xdg_data_files()&quot;</TT> and <TT>&quot;xdg_config_files()&quot;</TT> are exported for
backwards compatibility with version 0.02. They are identical to <TT>&quot;data_files()&quot;</TT>
and <TT>&quot;config_files()&quot;</TT> respectively but without the <TT>&quot;wantarray&quot;</TT> behavior.
<A NAME="lbAK">&nbsp;</A>
<H2>BUGS</H2>
Please mail the author if you encounter any bugs.
<A NAME="lbAL">&nbsp;</A>
<H2>AUTHOR</H2>
Jaap Karssenberg || Pardus [Larus] &lt;<A HREF="mailto:pardus@cpan.org">pardus@cpan.org</A>&gt;
<P>
Copyright (c) 2003, 2007 Jaap G Karssenberg. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
<P>
Currently being maintained by Kim Ryan
<A NAME="lbAM">&nbsp;</A>
<H2>SEE ALSO</H2>
&lt;<A HREF="http://www.freedesktop.org/wiki/Specifications/basedir-spec">http://www.freedesktop.org/wiki/Specifications/basedir-spec</A>&gt;
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="14"><A HREF="#lbAB">NAME</A><DD>
<DT id="15"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="16"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="17"><A HREF="#lbAE">EXPORT</A><DD>
<DT id="18"><A HREF="#lbAF">METHODS</A><DD>
<DL>
<DT id="19"><A HREF="#lbAG">Lookup</A><DD>
<DT id="20"><A HREF="#lbAH">Variables</A><DD>
</DL>
<DT id="21"><A HREF="#lbAI">NON-UNIX PLATFORMS</A><DD>
<DT id="22"><A HREF="#lbAJ">BACKWARDS COMPATIBILITY</A><DD>
<DT id="23"><A HREF="#lbAK">BUGS</A><DD>
<DT id="24"><A HREF="#lbAL">AUTHOR</A><DD>
<DT id="25"><A HREF="#lbAM">SEE ALSO</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:42 GMT, March 31, 2021
</BODY>
</HTML>