pkg('FTP::DirHandle') - Virtual FTP Server DirHandle
This module provides a directory handle object for use by Krang::FTP::Server.
This module inherits from Net::FTPServer::DirHandle and overrides the required methods. This class is used internally by Krang::FTP::Server.
Creates a new Krang::FTP::DirHandle object. Requires a Krang::FTP::Server object as its first parameter. Optionally takes a pathname, instance, type, and category_id. Type must correspond with media or template. If not supplied the pathname defaults to ``/''.
get($filename)
The get() method is used to do a lookup on a specific filename. If a
template or media object called $filename exists in this category then
get() will call Krang::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.
This method is called to open a file in the current directory. The possible modes are 'r', 'w' and 'a'. Same as get since we are not supporting new files here. The method returns a Krang::FTP::FileHandle or undef on failure.
list($wildcard)
The list() method is called to do a wildcard search inside a
directory. The method performs a search for categories and media/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 Krang::FTP::DirHandle object for the parent of this directory. For the root dir 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()
Renames a category (the analog of a directory). This method will fail and return -1 if the user doesn't have admin permission to manage categories via FTP, or if a category with the same name already exists.
delete()
Deletes a category (the analog of a directory). Will fail and return -1 if the user does not have admin privileges for category management via FTP, or if the category deletion or save throws an exception.
mkdir()
Creates a category (the analog of a directory) within the current category. Will fail and return -1 if the user does not have admin privileges for category management via FTP, or if the category creation or save fails.
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()
return true, and are supported, but return -1 if access is denied or if the
operation fails.
_can_manage_categories_via_ftp()
Returns true if user has admin permissions to manage categories via
FTP. This permission applies to the mkdir() and move() operations.
Net:FTPServer::DirHandle