.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "File::BaseDir 3pm" .TH File::BaseDir 3pm "2022-11-19" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" File::BaseDir \- Use the Freedesktop.org base directory specification .SH "VERSION" .IX Header "VERSION" version 0.09 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 4 \& use File::BaseDir qw/xdg_data_files/; \& for ( xdg_data_files(\*(Aqmime/globs\*(Aq) ) { \& # do something \& } .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" 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 \&\s-1GNOME, KDE\s0 or Xfce platforms follow this layout. However, the same layout can just as well be used for non-GUI applications. .PP This module forked from File::MimeInfo. .PP This module follows version 0.6 of BaseDir specification. .SH "CONSTRUCTOR" .IX Header "CONSTRUCTOR" .SS "new" .IX Subsection "new" .Vb 1 \& my $bd = File::BaseDir\->new; .Ve .PP Simple constructor to allow calling functions as object oriented methods. .SH "FUNCTIONS" .IX Header "FUNCTIONS" None of these are exported by default, but all functions can be exported by request. Also the groups \f(CW\*(C`:lookup\*(C'\fR and \f(CW\*(C`:vars\*(C'\fR are defined. The \&\f(CW\*(C`:vars\*(C'\fR group contains all the routines with a \f(CW\*(C`xdg_\*(C'\fR prefix. The \&\f(CW\*(C`:lookup\*(C'\fR group contains the routines to locate files and directories. .SS "data_home" .IX Subsection "data_home" .Vb 2 \& my $path = data_home(@path); \& my $path = $bd\->data_home(@path); .Ve .PP 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. .PP Example: .PP .Vb 3 \& # data_home is: /home/USER/.local/share \& $path = $bd\->data_home(\*(AqFoo\*(Aq, \*(AqBar\*(Aq, \*(AqBaz\*(Aq); \& # returns: /home/USER/.local/share/Foo/Bar/Baz .Ve .SS "data_dirs" .IX Subsection "data_dirs" .Vb 5 \& # :lookup \& my $dir = data_dirs(@path); \& my $dir = $bd\->data_dirs(@path); \& my @dirs = data_dirs(@path); \& my @dirs = $bd\->data_dirs(@path); .Ve .PP Looks for directories specified by \f(CW@path\fR 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. .SS "data_files" .IX Subsection "data_files" .Vb 5 \& # :lookup \& my $file = data_files(@path); \& my $file = $bd\->data_files(@path); \& my @files = data_files(@path); \& my @files = $bd\->data_files(@path); .Ve .PP Looks for files specified by \f(CW@path\fR 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. .SS "config_home" .IX Subsection "config_home" .Vb 3 \& # :lookup \& my $dir = config_home(@path); \& my $dir = $bd\->config_home(@path); .Ve .PP 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. .SS "config_dirs" .IX Subsection "config_dirs" .Vb 5 \& # :lookup \& my $dir = config_dirs(@path); \& my $dir = $bd\->config_dirs(@path); \& my @dirs = config_dirs(@path); \& my @dirs = $bd\->config_dirs(@path); .Ve .PP Looks for directories specified by \f(CW@path\fR 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. .SS "config_files" .IX Subsection "config_files" .Vb 5 \& # :lookup \& my $file = config_files(@path); \& my $file = $bd\->config_files(@path); \& my @files = config_files(@path); \& my @files = $bd\->config_files(@path); .Ve .PP Looks for files specified by \f(CW@path\fR 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. .SS "cache_home" .IX Subsection "cache_home" .Vb 3 \& # :lookup \& my $dir = cache_home(@path); \& my $dir = $bd\->cache_home(@path); .Ve .PP 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. .SS "xdg_data_home" .IX Subsection "xdg_data_home" .Vb 3 \& # :var \& my $dir = xdg_data_home; \& my $dir = $bd\->xdg_data_home; .Ve .PP Returns either \f(CW$ENV{XDG_DATA_HOME}\fR or it's default value. Default is \fI\f(CI$HOME\fI/.local/share\fR. .SS "xdg_data_dirs" .IX Subsection "xdg_data_dirs" .Vb 3 \& # :var \& my @dirs = xdg_data_dirs; \& my @dirs = $bd\->xdg_data_dirs; .Ve .PP Returns either \f(CW$ENV{XDG_DATA_DIRS}\fR or it's default value as list. Default is \fI/usr/local/share\fR, \fI/usr/share\fR. .SS "xdg_config_home" .IX Subsection "xdg_config_home" .Vb 3 \& # :var \& my $dir = xdg_config_home; \& my $dir = $bd\->xdg_config_home; .Ve .PP Returns either \f(CW$ENV{XDG_CONFIG_HOME}\fR or it's default value. Default is \fI\f(CI$HOME\fI/.config\fR. .SS "xdg_config_dirs" .IX Subsection "xdg_config_dirs" .Vb 3 \& # :var \& my @dirs = xdg_config_dirs; \& my @dirs = $bd\->xdg_config_dirs; .Ve .PP Returns either \f(CW$ENV{XDG_CONFIG_DIRS}\fR or it's default value as list. Default is \fI/etc/xdg\fR. .SS "xdg_cache_home" .IX Subsection "xdg_cache_home" .Vb 3 \& # :var \& my $dir = xdg_cache_home; \& my $dir = $bd\->xdg_cache_home; .Ve .PP Returns either \f(CW$ENV{XDG_CACHE_HOME}\fR or it's default value. Default is \fI\f(CI$HOME\fI/.cache\fR. .SH "NON-UNIX PLATFORMS" .IX Header "NON-UNIX PLATFORMS" The use of File::Spec ensures that all paths are returned in their native formats regardless of platform. On Windows this module will use the native environment variables, rather than the default on \s-1UNIX\s0 (which is traditionally \&\f(CW$HOME\fR). .PP 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. .SH "BACKWARDS COMPATIBILITY" .IX Header "BACKWARDS COMPATIBILITY" The methods \f(CW\*(C`xdg_data_files()\*(C'\fR and \f(CW\*(C`xdg_config_files()\*(C'\fR are exported for backwards compatibility with version 0.02. They are identical to \f(CW\*(C`data_files()\*(C'\fR and \f(CW\*(C`config_files()\*(C'\fR respectively but without the \f(CW\*(C`wantarray\*(C'\fR behavior. .SH "AUTHORS" .IX Header "AUTHORS" .IP "\(bu" 4 Jaap Karssenberg || Pardus [Larus] .IP "\(bu" 4 Graham Ollis .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2003\-2021 by Jaap Karssenberg || Pardus [Larus] . .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.