Skip to content

Commit 9dff68c

Browse files
Writer: append trailing slash to <= 15-byte GNU file names (blakesmith#14)
The GNU variant of the ar format expects all real file names to have trailing slashes, regardless of whether they are stored in the string table or in the file name header field.
1 parent 38b1713 commit 9dff68c

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

writer.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ func (aw *Writer) WriteHeader(hdr *Header) error {
216216
}
217217
aw.string(s.next(16), "/"+strconv.Itoa(offset))
218218
} else {
219+
// File names beginning with "/" aren't real file names - don't append "/" to them.
220+
if hdr.Name[0] != '/' {
221+
hdr.Name = hdr.Name + "/"
222+
}
219223
aw.string(s.next(16), hdr.Name)
220224
}
221225
case BSD:

0 commit comments

Comments
 (0)