From 554aaf0a89314827785ce6c8722f2b606e893a73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Cluseau?= Date: Mon, 30 Jun 2025 12:00:55 +0200 Subject: [PATCH] cpiocat: add AppendDir --- cpiocat/cpiocat.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cpiocat/cpiocat.go b/cpiocat/cpiocat.go index 85b33b2..f1c6852 100644 --- a/cpiocat/cpiocat.go +++ b/cpiocat/cpiocat.go @@ -157,6 +157,24 @@ func (c *Cat) AppendFile(srcPath, archPath string) (r *Cat) { return } +func (c *Cat) AppendDir(archPath string, mode cpio.FileMode) (r *Cat) { + r = c + if c.err != nil { + return + } + + var err error + defer func() { c.err = err }() + + const DIR_FLAG = 0o004 << 12 + err = c.cout.WriteHeader(&cpio.Header{ + Name: archPath, + Mode: mode | DIR_FLAG, + }) + + return +} + func (c *Cat) AppendBytes(content []byte, archPath string, mode cpio.FileMode) (r *Cat) { r = c if c.err != nil {