File-BaseDir-0.07000755000000000000 012515324222 14153 5ustar00unknownunknown000000000000File-BaseDir-0.07/Build.PL000444000000000000 104112515323755 15612 0ustar00unknownunknown000000000000#!/usr/bin/perl use Module::Build; my $build = Module::Build->new( dist_name => 'File-BaseDir', dist_version_from => 'lib/File/BaseDir.pm', dist_author => 'Jaap Karssenberg ', license => 'perl', requires => { 'Carp' => 0, 'Exporter' => 0, 'File::Spec' => 0, 'IPC::System::Simple' => 0 }, build_requires => { 'Module::Build' => '0.24', 'Test::More' => 0, 'File::Which' => 0, 'File::Temp' => 0 }, create_makefile_pl => 'small', ); $build->create_build_script; File-BaseDir-0.07/Changes000444000000000000 232612515323750 15613 0ustar00unknownunknown000000000000Revision history for Perl extension File::BaseDir. 0.07 21 Apr 2015 Use temporary files for 03_userdirs.t test, fix for RT bug 103805 0.06 6 Apr 2015 Added prerequsite module build_requires section of Build.PL 0.05 4 Apr 2015 Added prerequsitie module to Build.PL 0.04 3 Apr 2015 Fix for RT bug #41744 . Remove warning message when $ENV{HOME} is not defined Fix for RT bugs # 88502 and #54929, typos corrected Fix for RT bug #41744 . Remove warning message when $ENV{HOME} is not defined Fix for RT bugs #50343, added more functionality Fixed some OS depedendancies in test suite. 0.03 Wed Oct 24 2007 - Added lookup methods for files and dirs: data_home, data_files, data_dirs, config_home, config_files, config_dirs & cache_home; suggested by Matisse Enzer - Deprecated xdg_data_files and xdg_config_files; suggested by Michael Schwern - Added a bit of Win32 support - Extended tests to full coverage 0.02 Thu Sep 4 2003 - forgot to remove h2xs default "use 5.008" tag :( emergency release it is ... 0.01 Wed Sep 3 18:33:59 2003 - original version; created by h2xs 1.22 with options -AX -n File::BaseDir - Added methods for all environment variables defined by the spec File-BaseDir-0.07/configure000444000000000000 4710707712622 16163 0ustar00unknownunknown000000000000#!/bin/sh exec perl ./Makefile.PL "$@" File-BaseDir-0.07/Makefile.PL000444000000000000 43312515324222 16242 0ustar00unknownunknown000000000000# Note: this file was auto-generated by Module::Build::Compat version 0.4210 use Module::Build::Compat 0.02; Module::Build::Compat->run_build_pl(args => \@ARGV); require Module::Build; Module::Build::Compat->write_makefile(build_class => 'Module::Build'); File-BaseDir-0.07/MANIFEST000444000000000000 40312507357527 15435 0ustar00unknownunknown000000000000Build.PL Changes configure lib/File/BaseDir.pm lib/File/IconTheme.pm lib/File/UserDirs.pm Makefile.PL MANIFEST This list of files META.yml README t/01_vars.t t/02_lookup.t t/03_OO.t t/03_icontheme.t t/03_userdirs.t t/04_pod_ok.t t/05_pod_cover.t META.json File-BaseDir-0.07/META.json000444000000000000 266112515324222 15736 0ustar00unknownunknown000000000000{ "abstract" : "Use the Freedesktop.org base directory specification", "author" : [ "Jaap Karssenberg " ], "dynamic_config" : 1, "generated_by" : "Module::Build version 0.421", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "File-BaseDir", "prereqs" : { "build" : { "requires" : { "File::Temp" : "0", "File::Which" : "0", "Module::Build" : "0.24", "Test::More" : "0" } }, "configure" : { "requires" : { "Module::Build" : "0.42" } }, "runtime" : { "requires" : { "Carp" : "0", "Exporter" : "0", "File::Spec" : "0", "IPC::System::Simple" : "0" } } }, "provides" : { "File::BaseDir" : { "file" : "lib/File/BaseDir.pm", "version" : "0.07" }, "File::IconTheme" : { "file" : "lib/File/IconTheme.pm", "version" : "0.07" }, "File::UserDirs" : { "file" : "lib/File/UserDirs.pm", "version" : "0.07" } }, "release_status" : "stable", "resources" : { "license" : [ "http://dev.perl.org/licenses/" ] }, "version" : "0.07" } File-BaseDir-0.07/META.yml000444000000000000 156712515324222 15572 0ustar00unknownunknown000000000000--- abstract: 'Use the Freedesktop.org base directory specification' author: - 'Jaap Karssenberg ' build_requires: File::Temp: '0' File::Which: '0' Module::Build: '0.24' Test::More: '0' configure_requires: Module::Build: '0.42' dynamic_config: 1 generated_by: 'Module::Build version 0.421, CPAN::Meta::Converter version 2.142060' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: File-BaseDir provides: File::BaseDir: file: lib/File/BaseDir.pm version: '0.07' File::IconTheme: file: lib/File/IconTheme.pm version: '0.07' File::UserDirs: file: lib/File/UserDirs.pm version: '0.07' requires: Carp: '0' Exporter: '0' File::Spec: '0' IPC::System::Simple: '0' resources: license: http://dev.perl.org/licenses/ version: '0.07' File-BaseDir-0.07/README000444000000000000 124710707712622 15202 0ustar00unknownunknown000000000000File-BaseDir ============ This module can be used to find directories and files as specified by the Freedekstop.org Base Directory Specification. INSTALLATION To install this module type the following: perl Build.PL ./Build ./Build test ./Build install DEPENDENCIES This module requires these other modules which can be obtained from the CPAN if they are not allready installed on your system : Module::Build Carp Exporter File::Spec COPYRIGHT AND LICENCE 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. File-BaseDir-0.07/lib000755000000000000 012515324222 14721 5ustar00unknownunknown000000000000File-BaseDir-0.07/lib/File000755000000000000 012515324222 15600 5ustar00unknownunknown000000000000File-BaseDir-0.07/lib/File/BaseDir.pm000444000000000000 2005412515323414 17627 0ustar00unknownunknown000000000000package File::BaseDir; use strict; use Carp; require File::Spec; require Exporter; our $VERSION = 0.07; our @ISA = qw(Exporter); our %EXPORT_TAGS = ( vars => [ qw( xdg_data_home xdg_data_dirs xdg_config_home xdg_config_dirs xdg_cache_home ) ], lookup => [ qw( data_home data_dirs data_files config_home config_dirs config_files cache_home ) ], ); our @EXPORT_OK = ( qw(xdg_data_files xdg_config_files), map @$_, values %EXPORT_TAGS ); # Set root and home directories my $rootdir = File::Spec->rootdir(); if ($^O eq 'MSWin32') { $rootdir = 'C:\\'; # File::Spec default depends on CWD $ENV{HOME} ||= $ENV{USERPROFILE} || $ENV{HOMEDRIVE}.$ENV{HOMEPATH}; # logic from File::HomeDir::Windows } my $home = $ENV{HOME}; unless ($home) { # Default to operating system's home dir. NOTE: web applications may not have $ENV{HOME} assigned, # so don't issue a warning. See RT bug #41744 $home = $rootdir; } # Set defaults our $xdg_data_home = File::Spec->catdir($home, qw/.local share/); our @xdg_data_dirs = ( File::Spec->catdir($rootdir, qw/usr local share/), File::Spec->catdir($rootdir, qw/usr share/), ); our $xdg_config_home = File::Spec->catdir($home, '.config'); our @xdg_config_dirs = ( File::Spec->catdir($rootdir, qw/etc xdg/) ); our $xdg_cache_home = File::Spec->catdir($home, '.cache'); # OO method sub new { bless \$VERSION, shift } # what else is there to bless ? # Variable methods sub xdg_data_home { $ENV{XDG_DATA_HOME} || $xdg_data_home } sub xdg_data_dirs { ( $ENV{XDG_DATA_DIRS} ? _adapt($ENV{XDG_DATA_DIRS}) : @xdg_data_dirs ) } sub xdg_config_home {$ENV{XDG_CONFIG_HOME} || $xdg_config_home } sub xdg_config_dirs { ( $ENV{XDG_CONFIG_DIRS} ? _adapt($ENV{XDG_CONFIG_DIRS}) : @xdg_config_dirs ) } sub xdg_cache_home { $ENV{XDG_CACHE_HOME} || $xdg_cache_home } sub _adapt { map { File::Spec->catdir( split('/', $_) ) } split /[:;]/, shift; # ':' defined in the spec, but ';' is standard on win32 } # Lookup methods sub data_home { _catfile(xdg_data_home, @_) } sub data_dirs { _find_files(\&_dir, \@_, xdg_data_home, xdg_data_dirs) } sub data_files { _find_files(\&_file, \@_, xdg_data_home, xdg_data_dirs) } sub xdg_data_files { my @dirs = data_files(@_); return @dirs } sub config_home { _catfile(xdg_config_home, @_) } sub config_dirs { _find_files(\&_dir, \@_, xdg_config_home, xdg_config_dirs) } sub config_files { _find_files(\&_file, \@_, xdg_config_home, xdg_config_dirs) } sub xdg_config_files { my @dirs = config_files(@_); return @dirs } sub cache_home { _catfile(xdg_cache_home, @_) } sub _catfile { my $dir = shift; shift if ref $_[0] or $_[0] =~ /::/; # OO call return File::Spec->catfile($dir, @_); } sub _find_files { my $type = shift; my $file = shift; shift @$file if ref $$file[0] or $$file[0] =~ /::/; # OO call #warn "Looking for: @$file\n in: @_\n"; if (wantarray) { return grep { &$type( $_ ) && -r $_ } map { File::Spec->catfile($_, @$file) } @_; } else { # prevent unnecessary stats by returning early for (@_) { my $path = File::Spec->catfile($_, @$file); return $path if &$type($path) && -r $path; } } return (); } sub _dir { -d $_[0] } sub _file { -f $_[0] } 1; __END__ =head1 NAME File::BaseDir - Use the Freedesktop.org base directory specification =head1 SYNOPSIS use File::BaseDir qw/xdg_data_files/; for ( xdg_data_files('mime/globs') ) { # do something } =head1 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 L. This module follows version 0.6 of BaseDir specification. =head1 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. =head1 METHODS =over 4 =item C Simple constructor to allow Object Oriented use of this module. =back =head2 Lookup The following methods are used to lookup files and folders in one of the search paths. =over 4 =item C 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_home is: /home/USER/.local/share $path = $bd->data_home('Foo', 'Bar', 'Baz'); # returns: /home/USER/.local/share/Foo/Bar/Baz =item C Looks for directories specified by C<@PATH> 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. =item C Looks for files specified by C<@PATH> 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. =item C 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. =item C Looks for directories specified by C<@PATH> 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. =item C Looks for files specified by C<@PATH> 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. =item C 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. =back =head2 Variables The following methods only returns the value of one of the XDG variables. =over 4 =item C Returns either C<$ENV{XDG_DATA_HOME}> or it's default value. Default is F<$HOME/.local/share>. =item C Returns either C<$ENV{XDG_DATA_DIRS}> or it's default value as list. Default is F, F. =item C Returns either C<$ENV{XDG_CONFIG_HOME}> or it's default value. Default is F<$HOME/.config>. =item C Returns either C<$ENV{XDG_CONFIG_DIRS}> or it's default value as list. Default is F. =item C Returns either C<$ENV{XDG_CACHE_HOME}> or it's default value. Default is F<$HOME/.cache>. =back =head1 NON-UNIX PLATFORMS The use of L ensures that all paths are returned in the appropriate form for the current platform. On Windows this module will try to set C<$HOME> to a sensible value if it is not defined yet. On other platforms one can use e.g. L 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. =head1 BACKWARDS COMPATIBILITY The methods C and C are exported for backwards compatibility with version 0.02. They are identical to C and C respectively but without the C behavior. =head1 BUGS Please mail the author if you encounter any bugs. =head1 AUTHOR Jaap Karssenberg || Pardus [Larus] Epardus@cpan.orgE 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 =head1 SEE ALSO L File-BaseDir-0.07/lib/File/IconTheme.pm000444000000000000 251112515323456 20155 0ustar00unknownunknown000000000000package File::IconTheme; use strict; use warnings FATAL => 'all'; use File::BaseDir qw(data_dirs); require File::Spec; use parent qw(Exporter); our $VERSION = '0.07'; our @EXPORT_OK = qw(xdg_icon_theme_search_dirs); sub xdg_icon_theme_search_dirs { return grep {-d $_ && -r $_} File::Spec->catfile($ENV{HOME}, '.icons'), data_dirs('icons'), '/usr/share/pixmaps'; } 1; __END__ =head1 NAME File::IconTheme - find icon directories =head1 VERSION This document describes File::IconTheme. =head1 SYNOPSIS use File::IconTheme qw(xdg_icon_theme_search_dirs); print join "\n", xdg_icon_theme_search_dirs; =head1 DESCRIPTION This module can be used to find directories as specified by the Freedesktop.org Icon Theme Specification. Currently only a tiny (but most useful) part of the specification is implemented. In case you want to B an icon theme, use the directory returned by: use File::BaseDir qw(data_dirs); print scalar data_dirs('icons'); =head1 INTERFACE =over =item C Returns a list of the base directories of icon themes. =back =head1 EXPORTS None by default, but the method can be exported on demand. =head1 CONFIGURATION AND ENVIRONMENT C<$XDG_DATA_HOME>, C<$XDG_DATA_DIRS> =head1 SEE ALSO L File-BaseDir-0.07/lib/File/UserDirs.pm000444000000000000 721012515323444 20040 0ustar00unknownunknown000000000000package File::UserDirs; use strict; use warnings FATAL => 'all'; use IPC::System::Simple qw(capturex); use parent qw(Exporter); our $VERSION = '0.07'; our %EXPORT_TAGS = ( all => [ qw(xdg_desktop_dir xdg_documents_dir xdg_download_dir xdg_music_dir xdg_pictures_dir xdg_publicshare_dir xdg_templates_dir xdg_videos_dir) ]); our @EXPORT_OK = @{$EXPORT_TAGS{all}}; sub _xdg_user_dir { my ($purpose) = @_; my $dir = capturex 'xdg-user-dir', $purpose; chomp $dir; return $dir; } sub xdg_desktop_dir {return _xdg_user_dir 'DESKTOP';} sub xdg_documents_dir {return _xdg_user_dir 'DOCUMENTS';} sub xdg_download_dir {return _xdg_user_dir 'DOWNLOAD';} sub xdg_music_dir {return _xdg_user_dir 'MUSIC';} sub xdg_pictures_dir {return _xdg_user_dir 'PICTURES';} sub xdg_publicshare_dir {return _xdg_user_dir 'PUBLICSHARE';} sub xdg_templates_dir {return _xdg_user_dir 'TEMPLATES';} sub xdg_videos_dir {return _xdg_user_dir 'VIDEOS';} 1; __END__ =head1 NAME File::UserDirs - find extra media and documents directories =head1 VERSION This document describes File::UserDirs version C<0.04>. =head1 SYNOPSIS use File::UserDirs qw(:all); print xdg_desktop_dir; # e.g. /home/user/Desktop =head1 DESCRIPTION This module can be used to find directories as informally specified by the Freedesktop.org xdg-user-dirs software. This gives a mechanism to locate extra directories for media and documents files. =head1 INTERFACE =over =item C Returns the desktop directory. Unless changed by the user, this is the directory F in the home directory. =item C Returns the documents directory. Unless changed by the user, this is the home directory. =item C Returns the download directory. Unless changed by the user, this is the home directory. =item C Returns the music directory. Unless changed by the user, this is the home directory. =item C Returns the pictures directory. Unless changed by the user, this is the home directory. =item C Returns the public share directory. Unless changed by the user, this is the home directory. =item C Returns the templates directory. Unless changed by the user, this is the home directory. =item C Returns the videos directory. Unless changed by the user, this is the home directory. =back =head1 EXPORTS None by default, but any method can be exported on demand. Also the group C<:all> is defined which exports all methods. =head1 DIAGNOSTICS =over =item C<"xdg-user-dir" failed to start: %s> The executable C could not be run, most likely because it was not installed. See L. =back =head1 CONFIGURATION AND ENVIRONMENT The location of the directories can be specified by the user in the file F<$XDG_CONFIG_HOME/user-dirs.dirs>. It is a shell file setting a number of environment variables. To find the exact pathname from Perl, run: use File::BaseDir qw(config_home); print config_home('user-dirs.dirs'); =head2 Example customised F XDG_DESKTOP_DIR="$HOME/Workspace" XDG_DOCUMENTS_DIR="$HOME/Files" XDG_DOWNLOAD_DIR="$HOME/Files/Downloads" XDG_MUSIC_DIR="$HOME/Files/Audio" XDG_PICTURES_DIR="$HOME/Files/Images" XDG_PUBLICSHARE_DIR="$HOME/public_html" XDG_TEMPLATES_DIR="$HOME/Files/Document templates" XDG_VIDEOS_DIR="$HOME/Files/Video" =head1 DEPENDENCIES This module requires the executable F from the package C. Source code is available from L. =head1 SEE ALSO File-BaseDir-0.07/t000755000000000000 012515324222 14416 5ustar00unknownunknown000000000000File-BaseDir-0.07/t/01_vars.t000444000000000000 275110707712622 16226 0ustar00unknownunknown000000000000use strict; use Test::More tests => 12; use_ok('File::BaseDir', qw/:vars/); my $rootdir = ($^O eq 'MSWin32') ? 'c:\\' : File::Spec->rootdir(); ok(length($ENV{HOME}), 'HOME defined'); $ENV{XDG_CONFIG_HOME} = ''; ok( xdg_config_home() eq File::Spec->catdir($ENV{HOME}, qw/.config/), 'xdg_config_home default'); $ENV{XDG_CONFIG_HOME} = 'test123'; ok( xdg_config_home() eq 'test123', 'xdg_data_home set'); $ENV{XDG_CONFIG_DIRS} = ''; is_deeply( [xdg_config_dirs()], [ File::Spec->catdir($rootdir, qw/etc xdg/) ], 'xdg_config_dirs default'); $ENV{XDG_CONFIG_DIRS} = './t:foo:bar'; is_deeply( [xdg_config_dirs()], [File::Spec->catdir('.', 't'), 'foo', 'bar'], 'xdg_data_dirs set'); $ENV{XDG_DATA_HOME} = ''; ok( xdg_data_home() eq File::Spec->catdir($ENV{HOME}, qw/.local share/), 'xdg_data_home default'); $ENV{XDG_DATA_HOME} = 'test123'; ok( xdg_data_home() eq 'test123', 'xdg_data_home set'); $ENV{XDG_DATA_DIRS} = ''; is_deeply( [xdg_data_dirs()], [ File::Spec->catdir($rootdir, qw/usr local share/), File::Spec->catdir($rootdir, qw/usr share/) ], 'xdg_data_dirs default'); $ENV{XDG_DATA_DIRS} = './t:foo:bar'; is_deeply( [xdg_data_dirs()], [File::Spec->catdir('.', 't'), 'foo', 'bar'], 'xdg_data_dirs set'); $ENV{XDG_CACHE_HOME} = ''; ok( xdg_cache_home() eq File::Spec->catdir($ENV{HOME}, qw/.cache/), 'xdg_cache_home default'); $ENV{XDG_CACHE_HOME} = 'test123'; ok( xdg_cache_home() eq 'test123', 'xdg_cache_home set'); File-BaseDir-0.07/t/02_lookup.t000444000000000000 416410707712622 16565 0ustar00unknownunknown000000000000use strict; use Test::More tests => 17; use File::Spec; use_ok('File::BaseDir', qw/:lookup xdg_data_files xdg_config_files/); # Initalize test data: # t/ # `-- data/ $dir[1] # |-- dir/ $dir[2] # | `-- test $file[1] # `-- test $file[0] my @dir = ('t', map File::Spec->catdir(@$_), [qw/t data/], [qw/t data dir/] ); my @file = (map File::Spec->catfile(@$_), [qw/t data test/], [qw/t data dir test/] ); mkdir $dir[1] or die $! unless -d $dir[1]; mkdir $dir[2] or die $! unless -d $dir[2]; open TEST, ">$file[0]" or die $!; print TEST "test 1 2 3\n"; close TEST; eval { chmod 0644, $file[0] }; # reset previous run open TEST, ">$file[1]" or die $!; print TEST "test 1 2 3\n"; close TEST; $ENV{XDG_CONFIG_HOME} = 'foo'; $ENV{XDG_CONFIG_DIRS} = 'bar'; $ENV{XDG_DATA_HOME} = '.'; $ENV{XDG_DATA_DIRS} = join ':', @dir; is(data_home(qw/t data test/), $file[0], 'data_home'); is(data_files(qw/data test/), $file[0], 'data_files'); is_deeply([data_files(qw/test/)], \@file, 'data_files - list'); is(data_dirs(qw/data dir/), $dir[2], 'data_dirs'); is_deeply([data_dirs(qw/data dir/)], [$dir[2]], 'data_dirs - list'); ok(!data_files(qw/data dir/), 'data_files does not match dir'); ok(!data_dirs(qw/data test/), 'data_dirs does not match file'); is_deeply([xdg_data_files(qw/test/)], \@file, 'xdg_data_files - for backward compatibility'); $ENV{XDG_CONFIG_HOME} = '.'; $ENV{XDG_CONFIG_DIRS} = join ':', @dir; $ENV{XDG_DATA_HOME} = 'foo'; $ENV{XDG_DATA_DIRS} = 'bar'; is(config_home(qw/t data test/), $file[0], 'config_home'); is(config_files(qw/data test/), $file[0], 'config_files'); is_deeply([config_files(qw/test/)], \@file, 'config_files - list'); is(config_dirs(qw/data dir/), $dir[2], 'config_dirs'); is_deeply([config_dirs(qw/data dir/)], [$dir[2]], 'config_dirs - list'); is_deeply([xdg_config_files(qw/test/)], \@file, 'xdg_config_files - for backward compatibility'); SKIP: { eval { chmod 0200, $file[0] }; # make non-readable skip "chmod not supported", 1 if -r $file[0]; is(config_files(qw/test/), $file[1], 'config_files checks for read'); } $ENV{XDG_CACHE_HOME} = 't/data'; ok(cache_home('test') eq $file[0], 'data_cache'); File-BaseDir-0.07/t/03_icontheme.t000444000000000000 133212507401604 17215 0ustar00unknownunknown000000000000#!perl use strict; use warnings FATAL => 'all'; use Test::More; use Config; use File::IconTheme qw(xdg_icon_theme_search_dirs); require File::Spec; use File::Temp qw(); if ($^O eq 'MSWin32') { plan skip_all => 'File path comparisons cannot be made on MS Windows operating system.'; } else { plan tests => 1; } my @dirs = map {File::Temp->newdir} 0 .. 2; my @icondirs = map {File::Spec->catfile($_, 'icons')} @dirs; mkdir $_ for @icondirs; $ENV{XDG_DATA_HOME} = $dirs[0]; $ENV{XDG_DATA_DIRS} = $dirs[1] . $Config{path_sep} . $dirs[2]; is_deeply [xdg_icon_theme_search_dirs], [grep {-d $_ && -r $_} File::Spec->catfile($ENV{HOME}, '.icons'), @icondirs, '/usr/share/pixmaps' ]; File-BaseDir-0.07/t/03_OO.t000444000000000000 152410707712622 15567 0ustar00unknownunknown000000000000use strict; use Test::More tests => 6; use File::BaseDir; my $rootdir = ($^O eq 'MSWin32') ? 'c:\\' : File::Spec->rootdir(); my $conf = File::BaseDir->new; is(ref($conf), 'File::BaseDir', 'OO constructor works'); $ENV{XDG_DATA_DIRS} = ''; is_deeply( [$conf->xdg_data_dirs()], [ File::Spec->catdir($rootdir, qw/usr local share/), File::Spec->catdir($rootdir, qw/usr share/) ], 'xdg_data_dirs default - OO'); $ENV{XDG_DATA_HOME} = 't'; is($conf->data_dirs('data'), File::Spec->catdir(qw/t data/), 'data_dirs - OO'); is(File::BaseDir->data_dirs('data'), File::Spec->catdir(qw/t data/), 'data_dirs - Module'); is($conf->data_home('data', 'test'), File::Spec->catfile(qw/t data test/), 'data_home - OO'); is(File::BaseDir->data_home('data', 'test'), File::Spec->catfile(qw/t data test/), 'data_home - Module'); File-BaseDir-0.07/t/03_userdirs.t000444000000000000 274112515324162 17111 0ustar00unknownunknown000000000000#!perl use strict; use warnings FATAL => 'all'; use Test::More; use File::UserDirs qw(:all); use File::BaseDir qw(config_home); use File::Spec::Functions qw(catfile); use File::Which qw(which); use File::Temp qw(tempdir); my $xdg_user_dir_installed = 0; if (which 'xdg-user-dir') { plan tests => 8; $xdg_user_dir_installed = 1; } else { plan skip_all => '"xdg-user-dir" executable not found. Install package "xdg-user-dirs".'; } my $temphomedir = tempdir(CLEANUP => 1); local $ENV{HOME} = $temphomedir; mkdir "$temphomedir/.config"; my $udd = "$temphomedir/.config/user-dirs.dirs"; open my $fh, '>', $udd or die "could not open $udd for writing: $!"; print $fh <<'UDD'; XDG_DESKTOP_DIR="$HOME/Workspace" XDG_DOCUMENTS_DIR="$HOME/Files" XDG_DOWNLOAD_DIR="$HOME/Files/Downloads" XDG_MUSIC_DIR="$HOME/Files/Audio" XDG_PICTURES_DIR="$HOME/Files/Images" XDG_PUBLICSHARE_DIR="$HOME/public_html" XDG_TEMPLATES_DIR="$HOME/Files/Document templates" XDG_VIDEOS_DIR="$HOME/Files/Video" UDD close $fh; is xdg_desktop_dir, catfile($ENV{HOME}, 'Workspace'); is xdg_documents_dir, catfile($ENV{HOME}, 'Files'); is xdg_download_dir, catfile($ENV{HOME}, 'Files/Downloads'); is xdg_music_dir, catfile($ENV{HOME}, 'Files/Audio'); is xdg_pictures_dir, catfile($ENV{HOME}, 'Files/Images'); is xdg_publicshare_dir, catfile($ENV{HOME}, 'public_html'); is xdg_templates_dir, catfile($ENV{HOME}, 'Files/Document templates'); is xdg_videos_dir, catfile($ENV{HOME}, 'Files/Video'); File-BaseDir-0.07/t/04_pod_ok.t000444000000000000 25010707712622 16501 0ustar00unknownunknown000000000000use Test::More; eval "use Test::Pod 1.00"; plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; all_pod_files_ok( Test::Pod::all_pod_files(qw/bin lib/) ); File-BaseDir-0.07/t/05_pod_cover.t000444000000000000 46510707712622 17217 0ustar00unknownunknown000000000000use Test::More; use File::BaseDir qw/xdg_data_dirs/; $ENV{XDG_DATA_DIRS} = join ':', 'share', xdg_data_dirs; eval "use Test::Pod::Coverage 1.00"; plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD coverage" if $@; all_pod_coverage_ok( { also_private => [ qr/^_/, qr/^xdg_.*_files$/ ] } );