Bric::Util::FTP::DirHandle(3p)

NAME
Bric::Util::FTP::DirHandle - Virtual FTP Server DirHandle

VERSION
$LastChangedRevision$

DATE
$LastChangedDate: 2006-06-14 01:06:11 +0200 (Wed, 14 Jun 2006) $

DESCRIPTION
This module provides a directory handle object for use by Bric::Util::FTP::Server.

INTERFACE
This module inherits from Net::FTPServer::DirHandle and overrides the required methods. This class is used internally by Bric::Util::FTP::Server.

  Constructors

new($ftps, [$pathname, $oc_id, $category_id])
    Creates a new Bric::Util::FTP::DirHandle object. Requires a Bric::Util::FTP::Server object as its first parameter. Optionally takes a pathname, a site_id, an oc_id, and a category_id. If not supplied the pathname defaults to "/".

  Public Instance Methods

get($filename)
    The get() method is used to do a lookup on a specific filename. If a template called $filename exists in this category then get() will call Bric::Util::FTP::FileHandle->new() and return the object. If a category exists underneath this category called $filename then new() will be called and the directory handle will be returned. Failing that, undef is returned.

open($filename, $mode)
    This method is called to open a file in the current directory. The possible modes are 'r', 'w' and 'a'. It will return a Bric::Util::FTP::FileHandle object if the file exists and the user has permission to it. If they don't have permission, it returns "undef". If the file does not exist, it will be created (provided the user has CREATE permission) and the Bric::Util::FTP::FileHandle object returned.

list($wildcard)
    The list() method is called to do a wildcard search inside a directory. The method performs a search for categories and templates matching the specified wildcard. The return value is a reference to an array of two-element arrays - the first element is the name and the second is the corresponding FileHandle or DirHandle object. The results are sorted by names before being returned. If nothing matches the wildcard then a reference to an empty array is returned.

list_status($wildcard)
    This method performs the same as list() but also adds a third element to each returned array - the results of calling the status() method on the object. See the status() method below for details.

parent()
    Returns the Bric::FTP::DirHandle object for the parent of this directory. For the root directory it returns itself.

status()
    This method returns information about the object. The return value is a list with seven elements - ($mode, $perms, $nlink, $user, $group, $size, $time). To quote the good book (Net::FTPServer::Handle):

              $mode     Mode        'd' = directory,
                                    'f' = file,
                                    and others as with
                                    the find(1) -type option.
              $perms    Permissions Permissions in normal octal numeric format.
              $nlink    Link count
              $user     Username    In printable format.
              $group    Group name  In printable format.
              $size     Size        File size in bytes.
              $time     Time        Time (usually mtime) in Unix time_t format.

    In this case all of these values are fixed for all categories: ( 'd', 0777, 1, "nobody", "", 0, 0 ).

move()
    Unsupported method that always returns -1. Category management using the FTP interface will probably never be supported.

delete()
    Unsupported method that always returns -1. Category management using the FTP interface will probably never be supported.

mkdir()
    Unsupported method that always returns -1. Category management using the FTP interface will probably never be supported.

can_*()
    Returns permissions information for various activites. can_write(), can_enter() and can_list() all return true since these operations are supported on all categories. can_delete(), can_rename() and can_mkdir() all return false since these operations are never supported.

PRIVATE

  Private Functions

_get_cats()
    Returnes a reference to a hash of category information. Caches this data in a package global and returns the cached data if already called.

_forget_cats()
    Invalidates the cache used by _get_cats(). If the module ever provided operations that change catgeories then this method could be used to forget stale values.

AUTHOR
Sam Tregar <stregar@about-inc.com>

SEE ALSO
<Net:FTPServer::DirHandle>

Bric::Util::FTP::Server

Bric::Util::FTP::FileHandle