279 lines
7.1 KiB
HTML
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"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
File::BaseDir - Use the Freedesktop.org base directory specification
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
use File::BaseDir qw/xdg_data_files/;
|
|
for ( xdg_data_files('mime/globs') ) {
|
|
# do something
|
|
}
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAD"> </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"> </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"> </A>
|
|
<H2>METHODS</H2>
|
|
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="1">"new()"<DD>
|
|
|
|
|
|
|
|
|
|
Simple constructor to allow Object Oriented use of this module.
|
|
</DL>
|
|
<A NAME="lbAG"> </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">"data_home(@PATH)"<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->data_home('Foo', 'Bar', 'Baz');
|
|
# returns: /home/USER/.local/share/Foo/Bar/Baz
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="3">"data_dirs(@PATH)"<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">"data_files(@PATH)"<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">"config_home(@PATH)"<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">"config_dirs(@PATH)"<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">"config_files(@PATH)"<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">"cache_home(@PATH)"<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"> </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">"xdg_data_home"<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">"xdg_data_dirs"<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">"xdg_config_home"<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">"xdg_config_dirs"<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">"xdg_cache_home"<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"> </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"> </A>
|
|
<H2>BACKWARDS COMPATIBILITY</H2>
|
|
|
|
|
|
|
|
The methods <TT>"xdg_data_files()"</TT> and <TT>"xdg_config_files()"</TT> are exported for
|
|
backwards compatibility with version 0.02. They are identical to <TT>"data_files()"</TT>
|
|
and <TT>"config_files()"</TT> respectively but without the <TT>"wantarray"</TT> behavior.
|
|
<A NAME="lbAK"> </A>
|
|
<H2>BUGS</H2>
|
|
|
|
|
|
|
|
Please mail the author if you encounter any bugs.
|
|
<A NAME="lbAL"> </A>
|
|
<H2>AUTHOR</H2>
|
|
|
|
|
|
|
|
Jaap Karssenberg || Pardus [Larus] <<A HREF="mailto:pardus@cpan.org">pardus@cpan.org</A>>
|
|
<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"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
|
|
|
|
<<A HREF="http://www.freedesktop.org/wiki/Specifications/basedir-spec">http://www.freedesktop.org/wiki/Specifications/basedir-spec</A>>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </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>
|