mirror of
https://github.com/tsolomko/SWCompression.git
synced 2026-06-23 14:56:41 +00:00
[TAR] Add correctly set format property to TarEntryInfo
This commit is contained in:
@@ -91,6 +91,7 @@ public struct TarEntryInfo: ContainerEntryInfo {
|
||||
public let unknownExtendedHeaderRecords: [String: String]?
|
||||
|
||||
let specialEntryType: SpecialEntryType?
|
||||
let format: TarContainer.Format
|
||||
let hasRecognizedMagic: Bool
|
||||
|
||||
let blockStartIndex: Int
|
||||
@@ -208,6 +209,16 @@ public struct TarEntryInfo: ContainerEntryInfo {
|
||||
self.deviceMinorNumber = nil
|
||||
}
|
||||
|
||||
if local != nil || global != nil {
|
||||
self.format = .pax
|
||||
} else if magic == 0x00_20_20_72_61_74_73_75 || longName != nil || longLinkName != nil {
|
||||
self.format = .gnu
|
||||
} else if magic == 0x3030007261747375 || magic == 0x3030207261747375 {
|
||||
self.format = .ustar
|
||||
} else {
|
||||
self.format = .prePosix
|
||||
}
|
||||
|
||||
// Set `name` and `linkName` to values from PAX or GNU format if possible.
|
||||
self.name = ((local?.path ?? global?.path) ?? longName) ?? name
|
||||
self.linkName = ((local?.linkpath ?? global?.linkpath) ?? longLinkName) ?? linkName
|
||||
|
||||
Reference in New Issue
Block a user