File::BaseDir(3pm) | User Contributed Perl Documentation | File::BaseDir(3pm) |
File::BaseDir - Use the Freedesktop.org base directory specification
use File::BaseDir qw/xdg_data_files/; for ( xdg_data_files('mime/globs') ) { # do something }
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.
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.
The following methods are used to lookup files and folders in one of the search paths.
Example:
# data_home is: /home/USER/.local/share $path = $bd->data_home('Foo', 'Bar', 'Baz'); # returns: /home/USER/.local/share/Foo/Bar/Baz
The following methods only returns the value of one of the XDG variables.
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 $HOME to a sensible value if it is not defined yet. On other platforms one can use e.g. File::HomeDir to set $HOME 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 dependent behavior in this module should be considered an extension of the spec.
The methods "xdg_data_files()" and "xdg_config_files()" are exported for backwards compatibility with version 0.02. They are identical to "data_files()" and "config_files()" respectively but without the "wantarray" behavior.
Please mail the author if you encounter any bugs.
Jaap Karssenberg || Pardus [Larus] <pardus@cpan.org>
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.
Currently being maintained by Kim Ryan
<http://www.freedesktop.org/wiki/Specifications/basedir-spec>
2018-05-11 | perl v5.26.2 |