From 1a95ea72021614bee24ab1ba35533e9177d01b9a Mon Sep 17 00:00:00 2001 From: "Adam D. Ruppe" Date: Sat, 11 Jan 2020 23:08:55 -0500 Subject: [PATCH] handle bug from #233 comment about long name --- archive.d | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/archive.d b/archive.d index 453cab9..2e772a2 100644 --- a/archive.d +++ b/archive.d @@ -27,6 +27,12 @@ struct TarFile { } +/ +inout(char)[] upToZero(inout(char)[] a) { + int i = 0; + while(i < a.length && a[i]) i++; + return a[0 .. i]; +} + /++ A header of a file in the archive. This represents the @@ -56,8 +62,8 @@ struct TarFileHeader { const(char)[] filename() { import core.stdc.string; if(filenamePrefix_[0]) - return filenamePrefix_[0 .. strlen(filenamePrefix_.ptr)] ~ fileName_[0 .. strlen(fileName_.ptr)]; - return fileName_[0 .. strlen(fileName_.ptr)]; + return upToZero(filenamePrefix_[]) ~ upToZero(fileName_[]); + return upToZero(fileName_[]); } ///