home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / perl_ste.zip / auto / Net / FTP / mkdir.al < prev    next >
Text File  |  1997-11-28  |  677b  |  38 lines

  1. # NOTE: Derived from ./blib/lib/Net/FTP.pm.  Changes made here will be lost.
  2. package Net::FTP;
  3.  
  4. sub mkdir
  5. {
  6.  @_ == 2 || @_ == 3 or croak 'usage: $ftp->mkdir( DIR [, RECURSE ] )';
  7.  
  8.  my($ftp,$dir,$recurse) = @_;
  9.  
  10.  $ftp->_MKD($dir) || $recurse or
  11.     return undef;
  12.  
  13.  my $path = $dir;
  14.  
  15.  unless($ftp->ok)
  16.   {
  17.    my @path = split(m#(?=/+)#, $dir);
  18.  
  19.    $path = "";
  20.  
  21.    while(@path)
  22.     {
  23.      $path .= shift @path;
  24.  
  25.      $ftp->_MKD($path);
  26.      $path = $ftp->_extract_path($path);
  27.  
  28.      # 521 means directory already exists
  29.      last
  30.         unless $ftp->ok || $ftp->code == 521 || $ftp->code == 550;
  31.     }
  32.   }
  33.  
  34.  $ftp->_extract_path($path);
  35. }
  36.  
  37. 1;
  38.