summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSadeep Madurange <sadeep@asciimx.com>2026-04-10 22:09:15 +0800
committerSadeep Madurange <sadeep@asciimx.com>2026-04-10 22:09:15 +0800
commit714acb5a1500239e6c968254ba4448c35e047c8f (patch)
treeb1d67add47ff86c0892ab4d7ddb7fb05213f7fd7
parent35b9a686cb8c5473ad756f49ee293d8ed23e34e8 (diff)
downloadcvn-714acb5a1500239e6c968254ba4448c35e047c8f.tar.gz
wip: index streamer.
-rw-r--r--vcx32
1 files changed, 27 insertions, 5 deletions
diff --git a/vcx b/vcx
index b68d28d..17648a9 100644
--- a/vcx
+++ b/vcx
@@ -329,7 +329,7 @@ sub hash_file_content {
return $sha->hexdigest;
}
-sub get_dir_scanner {
+sub dir_streamer {
my (@paths) = @_;
my $chunk_size = 1024 * 64; # 64 KB chunks for IO buffering
@@ -352,13 +352,12 @@ sub get_dir_scanner {
print $tmp_fh @buf;
@buf = ();
$buf_size = 0;
- }
+ };
my @stack = @paths;
while (@stack) {
my $path = (pop @stack) =~ s|^\./||r;
my @st = lstat($path);
-
if (-d _) {
if (opendir(my $dh, $path)) {
push @stack, map { File::Spec->catfile($path, $_) }
@@ -394,7 +393,7 @@ sub get_dir_scanner {
chomp $line;
my ($p, $s, $m) = split(/\t/, $line);
return { path => $p, size => $s, mtime => $m };
- }
+ };
} else {
$flush->() if @buffer; # Clear remaining
close $tmp_fh;
@@ -412,6 +411,29 @@ sub get_dir_scanner {
chomp $line;
my ($p, $s, $m) = split(/\t/, $line);
return { path => $p, size => $s, mtime => $m };
- }
+ };
}
}
+
+sub index_streamer {
+ $index = INDEX;
+ open(my $fh, "<:utf8", $index) or die "Could not open index: $!";
+
+ return sub {
+ my $line = <$fh>;
+ unless (defined $line) {
+ close $fh;
+ return;
+ }
+
+ chomp $line;
+ my ($path, $size, $mtime, $hash) = split(/\t/, $line);
+
+ return {
+ path => $path,
+ size => $size,
+ mtime => $mtime,
+ hash => $hash,
+ };
+ };
+}