Lines Matching full:copy

22 use File::Copy qw(copy move cp);
25 # If we have Time::HiRes, File::Copy loaded it for us.
31 foreach my $code ("copy()", "copy('arg')", "copy('arg', 'arg', 'arg', 'arg')",
42 # Simulate a cross-partition copy/move by forcing rename to
54 copy "file-$$", "copy-$$";
56 open(F, "<", "copy-$$") or die $!;
60 is -s "file-$$", -s "copy-$$", 'copy(fn, fn): files of the same size';
62 is $foo, "ok\n", 'copy(fn, fn): same contents';
65 binmode STDOUT unless $^O eq 'VMS'; # Copy::copy works in binary mode
67 copy "copy-$$", \*STDOUT;
69 unlink "copy-$$" or die "unlink: $!";
73 copy(*F, "copy-$$");
74 open(R, "<:raw", "copy-$$") or die "open copy-$$: $!"; $foo = <R>; close(R);
75 is $foo, "ok\n", 'copy(*F, fn): same contents';
76 unlink "copy-$$" or die "unlink: $!";
80 copy(\*F, "copy-$$");
82 open(R, "<", "copy-$$") or die; $foo = <R>; close(R) or die "close: $!";
83 is $foo, "ok\n", 'copy(\*F, fn): same contents';
84 unlink "copy-$$" or die "unlink: $!";
87 my $fh = IO::File->new(">copy-$$") or die "Cannot open copy-$$:$!";
89 copy("file-$$",$fh);
91 open(R, "<", "copy-$$") or die; $foo = <R>; close(R);
92 is $foo, "ok\n", 'copy(fn, io): same contents';
93 unlink "copy-$$" or die "unlink: $!";
96 $fh = FileHandle->new(">copy-$$") or die "Cannot open copy-$$:$!";
98 copy("file-$$",$fh);
100 open(R, "<", "copy-$$") or die $!; $foo = <R>; close(R);
101 is $foo, "ok\n", 'copy(fn, fh): same contents';
104 ok !move("file-$$", "copy-$$"), "move on missing file";
105 ok -e "copy-$$", ' target still there';
109 utime( $time, $time, "copy-$$" );
114 my $mtime = (stat("copy-$$"))[9];
116 ok move("copy-$$", "file-$$"), 'move';
118 ok !-e "copy-$$", ' source does not';
127 "mtime preserved by copy()".
133 copy "file-$$", "lib";
135 is $foo, "ok\n", 'copy(fn, dir): same contents';
139 copy "file-$$", "lib";
141 is $foo, "ok\n", 'copy over the same file works';
147 ok !copy("file-$$", "file-$$"), 'copy to itself fails';
172 ok !copy("file-$$", "symlink-$$"), 'copy to itself (via symlink) fails';
193 ok !copy("file-$$", "hardlink-$$"), 'copy to itself (via hardlink) fails';
208 my $copy_msg = "this is copy\n";
209 open(F, ">", "copy-$$") or die $!;
219 is eval { copy("file-$$", "copy-$$", "pie-$$"); 1 }, undef,
220 "a bad buffer size fails to copy";
221 like $@, qr/Bad buffer size for copy/, "with a helpful error message";
226 is -s "copy-$$", length $copy_msg, "but does not truncate the destination";
227 open(F, "<", "copy-$$") or die $!;
233 unlink "copy-$$" or die $!;
235 # RT #73714 copy to file with leading whitespace failed
241 copy "file-$$", " copy-$$";
242 ok -e " copy-$$", "copy with leading whitespace";
244 unlink " copy-$$" or die "unlink: $!";
272 skip "-- Copy preserves RMS defaults, not POSIX permissions.", $skips
274 skip "Copy doesn't set file permissions correctly on Win32.", $skips
276 skip "Copy maps POSIX permissions to VOS permissions.", $skips
358 copy ($src, $copy1);
359 copy ($fh, $copy2);
360 copy ($src, $copy3);
423 is eval {copy $what{$left}, $what{$right}}, 0, "copy $left $right";
434 # On Unix systems, File::Copy always returns 0 to signal failure,
449 copy => \&File::Copy::copy,
450 cp => \&File::Copy::cp,
451 move => \&File::Copy::move,
452 mv => \&File::Copy::mv,
480 ok(copy($IN, $OUT), "copy pipe to another");
490 # RT #111126: File::Copy copy() zeros file when copying a file
504 ok(!copy($temp_file, $temp_dir),
505 "Copy of foo/file to foo/ should fail");
506 like($warn_message, qr/^\Q'$temp_file' and '$temp_file'\E are identical.*Copy\.t/i,
518 is eval {copy "file-$$", "copy-$$", $buffer}, 1,
519 "copy with buffer above normal size";
525 1 while unlink "copy-$$";