summary refs log tree commit diff
path: root/Rhea.Nar
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2026-08-14 13:26:59 +0200
committerRory& <root@rory.gay>2026-08-14 13:26:59 +0200
commit062b0d295675e5bf5129ea4a4a8f16ca4681e3dc (patch)
tree2529087a4be9c5e4fea66031092fc23444fadab5 /Rhea.Nar
parentDocument all public members of Rhea.Nar, some micro-optimisations (diff)
downloadRhea-062b0d295675e5bf5129ea4a4a8f16ca4681e3dc.tar.xz
Move validator to separate project
Diffstat (limited to 'Rhea.Nar')
-rw-r--r--Rhea.Nar/NarWriter.cs20
1 files changed, 18 insertions, 2 deletions
diff --git a/Rhea.Nar/NarWriter.cs b/Rhea.Nar/NarWriter.cs

index 0ca2e85..52bbb0e 100644 --- a/Rhea.Nar/NarWriter.cs +++ b/Rhea.Nar/NarWriter.cs
@@ -31,6 +31,22 @@ public class NarWriter foreach (var chunk in GetNarSymlinkContents(fe)) yield return chunk; } + + private IEnumerable<byte[]> GetNarStreamContentsInner(FileSystemInfo fsi) + { + if (string.IsNullOrWhiteSpace(fsi.LinkTarget)) + { + if (fsi is DirectoryInfo di) + foreach (var chunk in GetNarDirectoryContents(di)) + yield return chunk; + else + foreach (var chunk in GetNarFileContents(fsi as FileInfo ?? throw new Exception(fsi.GetType().Name +" != FileInfo"))) + yield return chunk; + } + else + foreach (var chunk in GetNarSymlinkContents(fsi)) + yield return chunk; + } private IEnumerable<byte[]> GetNarDirectoryContents(DirectoryInfo de) { @@ -43,7 +59,7 @@ public class NarWriter yield return GetLengthPrefixedPadded(fe.Name.AsBytes().ToArray()); yield return NarConsts.Node; - foreach (var chunk in GetNarStreamContentsInner(fe.FullName)) + foreach (var chunk in GetNarStreamContentsInner(fe)) yield return chunk; yield return NarConsts.RightParen; @@ -52,7 +68,7 @@ public class NarWriter yield return NarConsts.RightParen; } - private IEnumerable<byte[]> GetNarSymlinkContents(FileInfo fe) + private IEnumerable<byte[]> GetNarSymlinkContents(FileSystemInfo fe) { // yield return NarConsts.LeftParen; //