Flail::Exec::Cmd::open - Flail "open" command


flail documentation Contained in the flail distribution.

Index


Code Index:

NAME

Top

Flail::Exec::Cmd::open - Flail "open" command

VERSION

Top

  Time-stamp: <2006-12-03 11:09:17 attila@stalphonsos.com>

SYNOPSIS

Top

  use Flail::Exec::Cmd::open;
  blah;

DESCRIPTION

Top

Describe the module.

AUTHOR

Top

  attila <attila@stalphonsos.com>

COPYRIGHT AND LICENSE

Top


flail documentation Contained in the flail distribution.
package Flail::Exec::Cmd::open;
use strict;
use Carp;
use Flail::Utils;
use Mail::Folder;
use base qw(Exporter);
use vars qw(@EXPORT @EXPORT_OK %EXPORT_TAGS);
@EXPORT_OK = qw(flail_open);
@EXPORT = ();
%EXPORT_TAGS = ( 'cmd' => \@EXPORT_OK );
 
sub flail_open {
    my $fname = shift(@_);
    if ($fname eq "..") {
        if (defined($::FOLDER)) {
            $::FOLDER->sync;
            $::FOLDER->close;
            $::FOLDER = undef;
            $::FOLDER_NAME = undef;
            if ($::SUBDIR eq "") {
                print "you are in a twisty maze of folders, all alike (try ls)\n";
            } else {
                print "now in subfolder $::SUBDIR\n" unless $::Quiet;
            }
        } elsif ($::SUBDIR eq "") {
            print "you are in a mazy of twisty folders, all alike (try ls)\n";
        } else{
            my @x = split("/", $::SUBDIR);
            pop(@x);
            $::SUBDIR = join("/", @x);
            print "now in folder: $::SUBDIR\n" unless $::Quiet;
        }
        return;
    }
    my $fn = $::FolderDir . "/" . $fname;
    if (-d $fn) {
        $::SUBDIR = $fname;
        if (defined($::FOLDER)) {
            $::FOLDER->sync;
            $::FOLDER->close;
            $::FOLDER = undef;
            $::FOLDER_NAME = undef;
        }
        print "now in subfolder $::SUBDIR\n" unless $::Quiet;
        return;
    }
    if (!(-f $fn)) {
        print "no such folder: $fn\n";
        return;
    }
    my $folder = new Mail::Folder('AUTODETECT', $fn);
    if (!defined($folder)) {
        print "$fname: could not open ($fn): $!\n";
        return;
    }
    $::FOLDER->sync if defined($::FOLDER);
    $::FOLDER->close if defined($::FOLDER);
    $::FOLDER = $folder;
    $::FOLDER_NAME = $fname;
    print "$fname: openend with ", $folder->qty, " messages\n" unless $::Quiet;
}

1;

__END__

##
# Local variables:
# mode: perl
# tab-width: 4
# perl-indent-level: 4
# cperl-indent-level: 4
# cperl-continued-statement-offset: 4
# indent-tabs-mode: nil
# comment-column: 40
# time-stamp-line-limit: 40
# End:
##