Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Revert "Get rid of File::Copy", Puma's still using it

This reverts commit ed7310a.
  • Loading branch information...
commit 4587ca67afedf5e685ac5219df8bb21b39d7372c 1 parent 2835717
Tadeusz Sośnierz authored
Showing with 47 additions and 0 deletions.
  1. +34 −0 lib/File/Copy.pm
  2. +10 −0 t/02-file-copy.t
  3. +3 −0  t/test.file
34 lib/File/Copy.pm
View
@@ -0,0 +1,34 @@
+use v6;
+
+module File::Copy;
+
+sub cp(Str $from, Str $to) is export {
+ my $f1 = open $from, :r, :bin;
+ my $f2 = open $to, :w, :bin;
+ $f2.write($f1.read(4096)) until $f1.eof;
+ $f1.close;
+ $f2.close;
+}
+
+=begin pod
+
+=head1 NAME
+
+File::Copy -- copy files
+
+=head1 SYNOPSIS
+
+ use File::Copy;
+
+ cp 'source', 'destination';
+
+=head1 DESCRIPTION
+
+C<File::Copy> exports just one subroutine, cp taking two string
+parameters: source and destination. If something comes wrong, the
+internal open() or write() calls will die, C<copy()> has no special
+error reporting.
+
+=end pod
+
+# vim: ft=perl6
10 t/02-file-copy.t
View
@@ -0,0 +1,10 @@
+use v6;
+use Test;
+use File::Copy;
+
+cp 't/test.file', 't/another.file';
+is slurp('t/test.file'),
+ slurp('t/another.file'),
+ "copied file is identical";
+unlink 't/another.file';
+done;
3  t/test.file
View
@@ -0,0 +1,3 @@
+foo foo
+asd
+foo bar
Please sign in to comment.
Something went wrong with that request. Please try again.