1File::BaseDir(3)      User Contributed Perl Documentation     File::BaseDir(3)
2
3
4

NAME

6       File::BaseDir - Use the Freedesktop.org base directory specification
7

SYNOPSIS

9               use File::BaseDir qw/xdg_data_files/;
10               for ( xdg_data_files('mime/globs') ) {
11                       # do something
12               }
13

DESCRIPTION

15       This module can be used to find directories and files as specified by
16       the Freedesktop.org Base Directory Specification. This specifications
17       gives a mechanism to locate directories for configuration, application
18       data and cache data. It is suggested that desktop applications for e.g.
19       the Gnome, KDE or Xfce platforms follow this layout. However, the same
20       layout can just as well be used for non-GUI applications.
21
22       This module forked from File::MimeInfo.
23
24       This module follows version 0.6 of BaseDir specification.
25

EXPORT

27       None by default, but all methods can be exported on demand.  Also the
28       groups ":lookup" and ":vars" are defined. The ":vars" group contains
29       all routines with a "xdg_" prefix; the ":lookup" group contains the
30       routines to locate files and directories.
31

METHODS

33       "new()"
34           Simple constructor to allow Object Oriented use of this module.
35
36       Lookup
37
38       The following methods are used to lookup files and folders in one of
39       the search paths.
40
41       "data_home(@PATH)"
42           Takes a list of file path elements and returns a new path by
43           appending them to the data home directory. The new path does not
44           need to exist.  Use this when writing user specific application
45           data.
46
47           Example:
48
49             # data_home is: /home/USER/.local/share
50             $path = $bd->data_home('Foo', 'Bar', 'Baz');
51             # returns: /home/USER/.local/share/Foo/Bar/Baz
52
53       "data_dirs(@PATH)"
54           Looks for directories specified by @PATH in the data home and other
55           data directories. Returns (possibly empty) list of readable direc‐
56           tories. In scalar context only the first directory found is
57           returned. Use this to lookup application data.
58
59       "data_files(@PATH)"
60           Looks for files specified by @PATH in the data home and other data
61           directories. Only returns files that are readable. In scalar con‐
62           text only the first file found is returned. Use this to lookup
63           application data.
64
65       "config_home(@PATH)"
66           Takes a list of path elements and appends them to the config home
67           directory returning a new path. The new path does not need to
68           exist.  Use this when writing user specific configuration.
69
70       "config_dirs(@PATH)"
71           Looks for directories specified by @PATH in the config home and
72           other config directories. Returns (possibly empty) list of readable
73           directories. In scalar context only the first directory found is
74           returned. Use this to lookup configuration.
75
76       "config_files(@PATH)"
77           Looks for files specified by @PATH in the config home and other
78           config directories. Returns a (possibly empty) list of files that
79           are readable. In scalar context only the first file found is
80           returned.  Use this to lookup configuration.
81
82       "cache_home(@PATH)"
83           Takes a list of path elements and appends them to the cache home
84           directory returning a new path. The new path does not need to
85           exist.
86
87       Variables
88
89       The following methods only returns the value of one of the XDG vari‐
90       ables.
91
92       "xdg_data_home"
93           Returns either $ENV{XDG_DATA_HOME} or it's default value.  Default
94           is $HOME/.local/share.
95
96       "xdg_data_dirs"
97           Returns either $ENV{XDG_DATA_DIRS} or it's default value as list.
98           Default is /usr/local/share, /usr/share.
99
100       "xdg_config_home"
101           Returns either $ENV{XDG_CONFIG_HOME} or it's default value.
102           Default is $HOME/.config.
103
104       "xdg_config_dirs"
105           Returns either $ENV{XDG_CONFIG_DIRS} or it's default value as list.
106           Default is /etc/xdg.
107
108       "xdg_cache_home"
109           Returns either $ENV{XDG_CACHE_HOME} or it's default value.  Default
110           is $HOME/.cache.
111

NON-UNIX PLATFORMS

113       The use of File::Spec ensures that all paths are returned in the apro‐
114       priate form for the current platform. On Windows this module will try
115       to set $HOME to a sensible value if it is not defined yet. On other
116       platforms one can use e.g. File::HomeDir to set $HOME before loading
117       File::BaseDir.
118
119       Please note that the specification is targeting Unix platforms only and
120       will only have limited relevance on other platforms. Any platform
121       dependend behavior in this module should be considerd an extension of
122       the spec.
123

BACKWARDS COMPATIBILITY

125       The methods "xdg_data_files()" and "xdg_config_files()" are exported
126       for backwards compatibilty with version 0.02. They are identical to
127       "data_files()" and "config_files()" respectively but without the "wan‐
128       tarray" behavior.
129

BUGS

131       Please mail the author if you encounter any bugs.
132

AUTHOR

134       Jaap Karssenberg ⎪⎪ Pardus [Larus] <pardus@cpan.org>
135
136       Copyright (c) 2003, 2007 Jaap G Karssenberg. All rights reserved.  This
137       program is free software; you can redistribute it and/or modify it
138       under the same terms as Perl itself.
139

SEE ALSO

141       <http://www.freedesktop.org/wiki/Specifications/basedir-spec>
142
143
144
145perl v5.8.8                       2007-11-22                  File::BaseDir(3)
Impressum