# Copyright (c) 2006 bivio Software, Inc. All Rights Reserved. # # Visit http://www.bivio.biz for more info. # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; If not, you may get a copy from: # http://www.opensource.org/licenses/lgpl-license.html # # $Id: RootHandle.pm,v 1.2 2006/11/04 14:31:18 moeller Exp $ package Bivio::Ext::NetFTPServer::RootHandle; use strict; use base 'Bivio::Ext::NetFTPServer::DirHandle'; use Bivio::Biz::ListModel; our($VERSION) = sprintf('%d.%02d', q$Revision: 1.2 $ =~ /\d+/g); sub get { my($self, $filename) = @_; my($path) = '/' . $filename; return undef unless $self->{ftps}->get_realm_file($path); return Bivio::Ext::NetFTPServer::DirHandle->new($self->{ftps}, $path); } sub parent { my($self) = @_; return $self; } sub list_status { my($self, $wildcard) = @_; if ($wildcard) { $wildcard = $self->{ftps}->wildcard_to_regex($wildcard); } return Bivio::Biz::ListModel->new_anonymous({ primary_key => ['Forum.forum_id'], other => [ [qw(Forum.forum_id RealmOwner.realm_id)], ], order_by => ['RealmOwner.name'], })->map_iterate(sub { my($list) = @_; my($name) = $list->get('RealmOwner.name'); return () if $wildcard && $name !~ /$wildcard/; my($handle) = Bivio::Ext::NetFTPServer::DirHandle->new( $self->{ftps}, '/' . $name); # status will be empty if there is no Public folder my(@status) = $handle->status; return scalar(@status) ? [$name, $handle, [@status]] : (); }); } sub status { my($self) = @_; return ('d', 0555, 1, '', '', 1024, 0); } 1;