phoenix9 has asked for the wisdom of the Perl Monks concerning the following question:

I was attempting to copy a directory on windows with the dircopy subroutine of module File::Copy::Recursive. However whenever I run the program it claims the directory does not exist. For my code:

} else { print "\nAll songs found matches! ^_^ \n";} print "Copying Files....\n\n"; print "0% 100%\n"; my $div; {use integer; $div=(scalar keys %moves) / 25 + 1 ;} my $i = 0; foreach $dir (keys %moves) { unless (defined $opt{s}) {dircopy("$dir","$moves{$dir}") or die("\ +n!: Couldnt copy \"$dir\" : $!\n");} print "." if (($i % $div) == 0); $i++; }

i get:
All songs found matches! ^_^ Copying Files.... 0% 100% !: Couldnt copy "C:\Program Files\Stepmania CVS\Songs\Dance Dance Revo +lution 5th Mix\Abyss" : No such file or directory

%moves is generated dynamicly so I thought I might have messed up the generation routine. To check I added the lines:

... unless (defined $opt{s}) { print "it exists\n" if (-e $dir); #here print "its a dir\n" if (-d $dir); #and here dircopy("$dir","$moves{$dir}") or die("\n!: Couldnt copy \"$di +r\" : $!\n"); ...

to which I recieve:
... All songs found matches! ^_^ Copying Files.... 0% 100% it exists its a dir !: Couldnt copy "C:\Program Files\Stepmania CVS\Songs\Dance Dance Revo +lution 5th Mix\Abyss" : No such file or directory

What am I doing wrong? If the fault is with the module being none m$ compatible what should I use in its place?

Thanks In Advance, ~Phoenix9

Janitored by Arunbear - replaced pre tags with code tags, to prevent distortion of site layout.

Replies are listed 'Best First'.
Re: Copy a directory on windows
by poj (Abbot) on Aug 13, 2005 at 13:27 UTC
    The fault could be version 0.07 of the module returning zero even though the copy has completed OK.
    Upgrade to version 0.08 or later.
    Revision history for Perl extension File::Copy::Recursive. 0.10 Sat Aug 6 17:01:12 2005 - fixed indent in "SEE ALSO" POD that made it render badly - Added $PFSCheck 0.09 Fri Aug 5 18:59:11 2005 - made dircopy handle symlinks properly - made dircopy recursivley create a multiple directory target +dir if necessary - added $CPRFComp 0.08 Fri Jul 29 14:35:44 2005 - fixed side effect of 0.07 not returning properly
    poj
      thats possible, being on windows i got it via ppm so it may not be an up to date version I will try dl'in it via cpan and see if it works better.

      ~Phoenix9

        I updated the module and the copy seemed to work better but i still got an error, then I realized the file it was having trouble with now was trying to copy to a folder that's name had a "\" inb it and because this is windows it freaked out.



        Thanx for all the help,
        ~Phoenix9
Re: Copy a directory on windows
by Joost (Canon) on Aug 13, 2005 at 08:47 UTC
Re: Copy a directory on windows
by ambrus (Abbot) on Aug 13, 2005 at 10:04 UTC

    I'm not sure, but isn't the problem that you have swapped the two arguments of dircopy?

      In response to both above:


      I dont believe so the way %moves is set up is:
      "C:\Program Diles\Stepmania CVS\Songs\foo\bar" => "C:\Documents and S +ettings\Donald\Desktop\SM Extreme\Songs\foo\bar";
      (dynamically though) The file it is saying does not exist is defineitly $dir not  %moves{dir}

      ~Phoenix9