Codex

File::BaseDir

Section: User Contributed Perl Documentation (3pm)

Updated: 2010-02-24

Index?action=index Return to Main Contents


NAME

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

SYNOPSIS

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 Gnome, KDE or Xfce platforms follow this layout. However, the same layout can just as well be used for non-GUI applications.

This module forked from File::MimeInfo.

This module follows version 0.6 of BaseDir specification.

EXPORT

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.

METHODS

"new()"
Simple constructor to allow Object Oriented use of this module.:

Lookup

The following methods are used to lookup files and folders in one of the search paths.

"data_home(@PATH)"
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.

Example:

:
"data_dirs(@PATH)"
Looks for directories specified by 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.:
"data_files(@PATH)"
Looks for files specified by 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.:
"config_home(@PATH)"
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.:
"config_dirs(@PATH)"
Looks for directories specified by 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.:
"config_files(@PATH)"
Looks for files specified by 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.:
"cache_home(@PATH)"
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.:

Variables

The following methods only returns the value of one of the XDG variables.

"xdg_data_home"
Returns either or it's default value. Default is $HOME/.local/share.:
"xdg_data_dirs"
Returns either or it's default value as list. Default is /usr/local/share, /usr/share.:
"xdg_config_home"
Returns either or it's default value. Default is $HOME/.config.:
"xdg_config_dirs"
Returns either or it's default value as list. Default is /etc/xdg.:
"xdg_cache_home"
Returns either or it's default value. Default is $HOME/.cache.:

NON-UNIX PLATFORMS

The use of File::Spec ensures that all paths are returned in the apropriate form for the current platform. On Windows this module will try to set to a sensible value if it is not defined yet. On other platforms one can use e.g. File::HomeDir to set before loading File::BaseDir.

Please note that the specification is targeting Unix platforms only and will only have limited relevance on other platforms. Any platform dependend behavior in this module should be considerd an extension of the spec.

BACKWARDS COMPATIBILITY

The methods and are exported for backwards compatibility with version 0.02. They are identical to and respectively but without the behavior.

BUGS

Please mail the author if you encounter any bugs.

AUTHOR

Jaap Karssenberg || Pardus [Larus] <[email protected]>

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.

SEE ALSO

<http://www.freedesktop.org/wiki/Specifications/basedir-spec>


Index

NAME

SYNOPSIS

DESCRIPTION

EXPORT

METHODS

Lookup

Variables

NON-UNIX PLATFORMS

BACKWARDS COMPATIBILITY

BUGS

AUTHOR

SEE ALSO