> [EMAIL PROTECTED] wrote:
> > ----- Original Message -----
> > From: Rob Dixon <[EMAIL PROTECTED]>
> > Date: Thursday, July 10, 2003 11:36 am
> > Subject: Re: Net::FTP
> >
> > > Dan Muey wrote:
> > > > > > What I'd like to do is simply:
> > > > > > (WHERE exists() is hopefully a solution to my first
> > > > > > question)
> > > > > >
> > > > > >  if($ftp->exists($file)) {
> > > > > > $ftp->delete($file);
> > > > > > if($ftp->exists($file)) { print "Could not delete $file"; } 
> > > > > > else { print "$file is all gone"; }  } else { print "$file 
> > > > > > does
> > > > > not exist so
> > > > > > I did not even try to delete it" }
> > > > >
> > > > > 'size' is the way to do it, but remember that it will return 
> > > > > zero for a file of zero size. What you need is 'defined'.
> > > > >
> > > > > This little subroutine will fulfil your wishes and 
> make the code 
> > > > > above work.
> > > > >
> > > > >   sub Net::FTP::exists {
> > > > >     my $ftp = shift;
> > > > >     defined $ftp->size(@_);
> > > > >   }
> > > > >
> > > > > HTH,
> > > >
> > > > As always Rob a huge help. I'll play around with that. 
> It's makes 
> > > > so much sense when you think about it! I'll tuck that one away 
> > > > under my big hat too!
> > > >
> > >
> > > Glad to help. FTP's a pain: as far as I know there's no way of 
> > > telling whether a filename is a plain file or a directory either, 
> > > without either trying to 'cwd' to it or parsing the 
> output or 'dir'.
> > you probebly can tell if its a directory. just grab the first 1024 
> > bytes, and look inside it. Will be eassy if its laying on 
> top of UFS 
> > or FFS
> 
> That depends on your file system. I don't think
> most would let you open a directory as a plain file.
> 
> What I'm pining for is something like
> 
>   $ftp->stat('entity');
> 
> Dan will tell us when he's written it :)

Actually I have some stuff together already:
I have the exists() (stolen from Rob ;p), isfile(), isdir(), lsname() which is like 
$ftp->ls() except it returns a list of file names in a directory without the path in 
front of it.
And they all work!

Now the hard part is making into a package that people can install via CPAN and has 
all the docs etc..

Any body got any links ot documentation about the best way to do that? 
I seem to remember some program that generates all the necessary files for you and you 
just add the guts.
Also I have to figurer out a name and get my cpan accoutn and everything.

Any who I'll let you all know!
Thanks for the encouragment Rob!
DMuey

> 
> Rob


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to