]> Sergey Matveev's repositories - zk.git/commitdiff
More efficient file copying
authorSergey Matveev <stargrave@stargrave.org>
Thu, 8 May 2025 11:46:26 +0000 (14:46 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Thu, 8 May 2025 15:05:15 +0000 (18:05 +0300)
zk

diff --git a/zk b/zk
index bebc2eee3064a5a7cdc88e0cebd9df53371780a6..621cfa1062e1cbe7add742c99cedba05387ef8bb 100755 (executable)
--- a/zk
+++ b/zk
@@ -354,6 +354,7 @@ if ($ARGV[0] eq "dump") {
 } elsif ($ARGV[0] eq "htmls") {
     my $now = time;
     use File::Path qw(make_path);
+    use File::Copy;
     foreach my $cat (keys %cats) {
         make_path "$ARGV[1]/$cat";
         next if (exists $mtimes{"$cat/index"});
@@ -370,11 +371,7 @@ if ($ARGV[0] eq "dump") {
         close $fh;
         @s = stat($pth) or die "$!";
         utime $s[9], $s[9], "$ARGV[1]/$pth.html";
-        open(my $in, "<", $pth) or die "$!";
-        open(my $out, ">", "$ARGV[1]/$pth.txt") or die "$!";
-        while (<$in>) { print $out $_ };
-        close $out;
-        close $in;
+        copy $pth, "$ARGV[1]/$pth.txt" or die "$!";
         utime $s[9], $s[9], "$ARGV[1]/$pth.txt";
     }
 } elsif ($ARGV[0] eq "dot") {