NAME

Any::Daemon::HTTP::Directory - describe a server directory

INHERITANCE

Any::Daemon::HTTP::Directory
  is a Any::Daemon::HTTP::Source

Any::Daemon::HTTP::Directory is extended by
  Any::Daemon::HTTP::UserDirs

SYNOPSIS

# implicit creation of ::Directory object
my $vh = Any::Daemon::HTTP::VirtualHost
  ->new(directories => {path => '/', location => ...})

my $vh = Any::Daemon::HTTP::VirtualHost
  ->new(directories => [ \%dir1, \%dir2, $dir_obj ])

# explicit use
my $root = Any::Daemon::HTTP::Directory
  ->new(path => '/', location => '...');
my $vh = Any::Daemon::HTTP::VirtualHost
  ->new(directories => $root);

DESCRIPTION

Each Any::Daemon::HTTP::VirtualHost will define where the files are located. Parts of the URI path can map on different (virtual) directories, with different access rights.

See documentation in the base class.

METHODS

See documentation in the base class.

Constructors

See documentation in the base class.

Any::Daemon::HTTP::Directory->new(OPTIONS|HASH-of-OPTIONS)
-Option        --Defined in               --Default
 allow           Any::Daemon::HTTP::Source  <undef>
 charset                                    utf-8
 deny            Any::Daemon::HTTP::Source  <undef>
 directory_list                             <false>
 index_file                                 ['index.html', 'index.htm']
 location                                   <required>
 name            Any::Daemon::HTTP::Source  path
 path            Any::Daemon::HTTP::Source  '/'
allow => CIDR|HOSTNAME|DOMAIN|CODE|ARRAY
charset => STRING

The character-set which is used all text-files on the system, used in response headers of text-files.

deny => CIDR|HOSTNAME|DOMAIN|CODE|ARRAY
directory_list => BOOLEAN

Enables the display of a directory, when it does not contain one of the index_file prepared defaults.

index_file => STRING|ARRAY

When a directory is addressed, it is scanned whether one of these files exist. If so, the content will be shown.

location => DIRECTORY|CODE

The DIRECTORY to be prefixed before the path of the URI, or a CODE reference which will rewrite the path (passed as only parameter) into the absolute file or directory name.

name => STRING
path => PATH

Attributes

See documentation in the base class.

$obj->charset()
$obj->location()
$obj->name()

See "Attributes" in Any::Daemon::HTTP::Source

$obj->path()

See "Attributes" in Any::Daemon::HTTP::Source

Permissions

See documentation in the base class.

$obj->allow(SESSION, REQUEST, URI)

See "Permissions" in Any::Daemon::HTTP::Source

$obj->collect(VHOST, SESSION, REQUEST, URI)

See "Permissions" in Any::Daemon::HTTP::Source

Actions

See documentation in the base class.

$obj->filename(PATH)

Convert a URI PATH into a directory path. Return undef if not possible.

$obj->list(DIRECTORY, OPTIONS)

Returns a HASH with information about the DIRECTORY content. This may be passed into some template or the default template. See "Return of directoryList" about the returned output.

-Option       --Default
 filter         <undef>
 hide_symlinks  <false>
 names          <skip hidden files>
filter => CODE

For each of the selected names (see names option) the lstat() is called. That data is expanded into a HASH, but not all additional fields are yet filled-in (only the ones which come for free).

names => CODE|Regexp

Reduce the returned list. The CODE reference is called with the found filename, and should return true when the name is acceptable. The default regexp (on UNIX) is qr/^[^.]/

DETAILS

See documentation in the base class.

Resource restrictions

See documentation in the base class.

Return of list()

The list() method returns a HASH of HASHes, where the primary keys are the directory entries, each refering to a HASH with details. It is designed to ease the connection to template systems.

The details contain the lstat information plus some additional helpers. The lstat call provides the fields dev, ino, mode, nlink, uid, gid, rdev, size, atime, mtime, ctime, blksize, blocks -as far as supported by your OS. The entry's name and path are added.

The kind field contains the string DIRECTORY, FILE, SYMLINK, or OTHER. Besides, you get either an is_directory, is_file, is_symlink, or is_other field set to true. Equivalent are:

if($entry->{kind} eq 'DIRECTORY')
if($entry->{is_directory})

It depends on the kind of entry which of the following fields are added additionally. Symlinks will get symlink_dest, symlink_dest_exists. Files hace the size_nice, which is the size in pleasant humanly readable format.

Files and directories have the mtime_nice (in localtime). The user and group which are textual representations of the numeric uid and gid are added. The flags represents the UNIX standard permission-bit display, as produced by the "ls -l" command.

SEE ALSO

This module is part of Any-Daemon-HTTP distribution version 0.24, built on January 05, 2014. Website: http://perl.overmeer.net/any-daemon/

LICENSE

Copyrights 2013-2014 by [Mark Overmeer]. For other contributors see ChangeLog.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html