about summary refs log tree commit diff
path: root/t/treegen
diff options
context:
space:
mode:
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;
+    }
+}