handle bug from #233 comment about long name

This commit is contained in:
Adam D. Ruppe 2020-01-11 23:08:55 -05:00
parent 4702c672ca
commit 1a95ea7202
1 changed files with 8 additions and 2 deletions

View File

@ -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 A header of a file in the archive. This represents the
@ -56,8 +62,8 @@ struct TarFileHeader {
const(char)[] filename() { const(char)[] filename() {
import core.stdc.string; import core.stdc.string;
if(filenamePrefix_[0]) if(filenamePrefix_[0])
return filenamePrefix_[0 .. strlen(filenamePrefix_.ptr)] ~ fileName_[0 .. strlen(fileName_.ptr)]; return upToZero(filenamePrefix_[]) ~ upToZero(fileName_[]);
return fileName_[0 .. strlen(fileName_.ptr)]; return upToZero(fileName_[]);
} }
/// ///