about summary refs log tree commit diff
path: root/t/treegen
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2021-06-25 21:24:47 +0200
committerLeah Neukirchen <leah@vuxu.org>2021-06-25 21:28:19 +0200
commit32c82229d93471c25eaaaed5e76704893162a125 (patch)
tree7f396797c397dac8121fd8742d7eb9aa1cd90b64 /t/treegen
parentca309754c6aba81be4f290279666a68f75306d70 (diff)
downloadlr-32c82229d93471c25eaaaed5e76704893162a125.tar.gz
lr-32c82229d93471c25eaaaed5e76704893162a125.tar.xz
lr-32c82229d93471c25eaaaed5e76704893162a125.zip
add partial test suite testsuite
Diffstat (limited to 't/treegen')
-rwxr-xr-xt/treegen30
1 files changed, 30 insertions, 0 deletions
diff --git a/t/treegen b/t/treegen
new file mode 100755
index 0000000..1b7f0c9
--- /dev/null
+++ b/t/treegen
@@ -0,0 +1,30 @@
+#!/usr/bin/perl -w
+use v5.16;
+
+use File::Spec;
+use File::Path qw(make_path);
+
+# [fdl]
+while (<>) {
+    if (/^f:(.*?)(?::(\d+))?(?::(\d+))?$/) {
+        my $path = $1;
+        my ($_volume, $dir, $_base) = File::Spec->splitpath($path);
+        my $size = $2 || 0;
+        my $mode = $3 ? oct($3) : 0644;
+
+        make_path($dir)  if $dir;
+        open(my $out, ">", "$path") or die "can't create $path";
+        chmod($mode, $out);
+        truncate($out, $size);
+        close($out);
+    } elsif (/^d:(.*)$/) {
+        make_path($1, {mode => 0755});
+    } elsif (/^l:(.*?):(.*)$/) {
+        my $target = $1;
+        my $linkname = $2;
+        my ($_volume, $dir, $_base) = File::Spec->splitpath($linkname);
+
+        make_path($dir)  if $dir;
+        symlink $target, $linkname;
+    }
+}