Skip Menu |

This queue is for tickets about the File-Copy-Recursive CPAN distribution.

Report information
The Basics
Id: 11644
Status: resolved
Priority: 0/
Queue: File-Copy-Recursive

People
Owner: Nobody in particular
Requestors: ofer [...] netapt.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.04
Fixed in: 0.05



Subject: wrong behavior when copying to '.'
When I do the following: rcopy( '/somedir/foo', '.' ) I expect the foo file to be copied to my current working directory, mode intact and everything. However: 1) if I'm copying an executable, the executable mode seems to disappear 2) if I'm copying a directory, rather than the directory being copied, the contents of the directory are copied instead For example, I assume I have the following: /somedir/foo/file1 /somedir/foo/file2 and I'm in /home/ofer, and I run a script with: rcopy( '/somedir/foo', '.' ); what I expect to end up with is: /home/ofer/foo/file1 /home/ofer/foo/file2 what I get instead is /home/ofer/file1 /home/ofer/file2 Both of these bugs can be avoided by explicitly stating the target name: rcopy( '/somedir/foo', 'foo' ); But often it's convenient to just say '.', as in copy it to my local dir. Sometimes you just have a path, and don't want to take the time to parse out the filename so you can pass it as the second arg.
I'll look into it ASAP, thanks for the info :)
mod_test.pl is: #!/usr/bin/perl use strict; use warnings; use File::Copy::Recursive; my ($f,$d,$l) = File::Copy::Recursive::rcopy($ARGV[0],$ARGV[1]) or die $!; print "File: $f\nDir: $d\nLevel: $l\n"; I made a directory structure with some 644, 777, 775 permissions Before: multivac:~/filerec dmuey$ ls -Rlph total 8 -rwxr-xr-x 1 dmuey dmuey 565B 4 Mar 09:06 mod_test.pl drwxr-xr-x 4 dmuey dmuey 136B 4 Mar 09:05 orig/ ./orig: total 0 -rw-r--r-- 1 dmuey dmuey 0B 4 Mar 09:05 file drwxr-xr-x 4 dmuey dmuey 136B 4 Mar 09:05 foo/ ./orig/foo: total 0 drwxrwxrwx 3 dmuey dmuey 102B 4 Mar 09:06 bar/ -rwxr-xr-x 1 dmuey dmuey 0B 4 Mar 09:05 script ./orig/foo/bar: total 0 -rw-r--r-- 1 dmuey dmuey 0B 4 Mar 09:06 baz multivac:~/filerec dmuey$ After: multivac:~/filerec dmuey$ ./mod_test.pl ./orig/ . File: 6 Dir: 3 Level: 3 multivac:~/filerec dmuey$ ls -Rlph total 8 -rw-r--r-- 1 dmuey dmuey 0B 4 Mar 09:11 file drwxr-xr-x 4 dmuey dmuey 136B 4 Mar 09:11 foo/ -rwxr-xr-x 1 dmuey dmuey 565B 4 Mar 09:06 mod_test.pl drwxr-xr-x 4 dmuey dmuey 136B 4 Mar 09:05 orig/ ./foo: total 0 drwxrwxrwx 3 dmuey dmuey 102B 4 Mar 09:11 bar/ -rwxr-xr-x 1 dmuey dmuey 0B 4 Mar 09:11 script ./foo/bar: total 0 -rw-r--r-- 1 dmuey dmuey 0B 4 Mar 09:11 baz ./orig: total 0 -rw-r--r-- 1 dmuey dmuey 0B 4 Mar 09:05 file drwxr-xr-x 4 dmuey dmuey 136B 4 Mar 09:05 foo/ ./orig/foo: total 0 drwxrwxrwx 3 dmuey dmuey 102B 4 Mar 09:06 bar/ -rwxr-xr-x 1 dmuey dmuey 0B 4 Mar 09:05 script ./orig/foo/bar: total 0 -rw-r--r-- 1 dmuey dmuey 0B 4 Mar 09:06 baz multivac:~/filerec dmuey$ So it seems to work... Did you set $File::Copy::Recursive::KeepMode to a false value? The code that does it is: chmod scalar((stat($org))[2]), $new if $KeepMode; Where $org is the original filename and $new is the new file name. Maybe your Perl doesn't like that for some reason? What does perl -mstrict -we 'print scalar((stat("your.orig.filename.here"))[2]),"\n";' ouput? If its right, what effect does perl -mstrict -we ' chmod scalar(stat("your.orig.filename.here"))[2]), "new.file";' have?