pub fn parseName(
self: *const ArchiveMemberHeader,
opt_longnames: ?[]const u8,
) ![]const u8 self: *const ArchiveMemberHeaderopt_longnames: ?[]const u82029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052 pub fn parseName(
self: *const ArchiveMemberHeader,
opt_longnames: ?[]const u8,
) ![]const u8 {
const trim = std.mem.trimEnd(u8, &self.name, &.{' '});
if (trim.len == 0) return error.BadName;
return if (trim[0] == '/') name: {
if (trim.len == 1 or
trim.len == 2 and trim[1] == '/')
break :name trim;
const offset = std.fmt.parseUnsigned(u50, trim[1..], 10) catch
return error.BadName;
if (opt_longnames) |longnames| {
if (offset >= longnames.len) return error.BadName;
break :name std.mem.sliceTo(longnames[@intCast(offset)..], 0);
} else return error.NoLongNames;
} else if (trim[trim.len - 1] == '/')
trim[0 .. trim.len - 1]
else
return error.BadName;
}
Extracts the name of the member by either reading it directly from the header, or by finding it inside the longnames member, if provided.