cpiocat: add AppendDir

This commit is contained in:
Mikaël Cluseau
2025-06-30 12:00:55 +02:00
parent 648e16ad98
commit 554aaf0a89

View File

@ -157,6 +157,24 @@ func (c *Cat) AppendFile(srcPath, archPath string) (r *Cat) {
return 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) { func (c *Cat) AppendBytes(content []byte, archPath string, mode cpio.FileMode) (r *Cat) {
r = c r = c
if c.err != nil { if c.err != nil {