[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl-Toolbox] Moving files from hiden folder



At 6.35 -0400 1999.07.19, jean-michel meyer wrote:
>Is it a nice and elegant way to move files and folders from a hidden
>folder, without res fork, to a  normal folder, using MP ?
>I gues yes, using the command :  FSpFileCopy or FSpDirectoryCopy of
>Mac::MoreFile.pm , or with File::Copy.pm modules.

Yes.

File::Copy uses the Mac toolbox functions to do a proper copy.  So it is
proper to use it, and it will Do The Right Thing.  However, I don't think
File::Copy does a directory copy.  You might have to roll your own.  Though
I would use File::Find and File::Path with File::Copy to make it more
portable:

  # untested code
  use File::Copy;
  use File::Find;
  use File::Path;

  my $dir = 'foo:bar:';
  my $dest = 'bar:foo:';
  find(\&copy_stuff, $dir);

  sub copy_stuff {
    my $name = $File::Find::name;
    my $copy = s/^\Q$dir/$dest/;
    if (-d $name) {
      mkpath($copy) unless -e $copy;
    } else {
      copy($name, $copy) or warn $!;
    }
  }

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-toolbox-request@macperl.org