mirror of
https://github.com/tsolomko/SWCompression.git
synced 2026-06-23 14:56:41 +00:00
[TAR] Add fileprivate extension to Data which works like String.padding and Data.prefix combined
This commit is contained in:
@@ -255,3 +255,15 @@ public struct TarEntryInfo: ContainerEntryInfo {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fileprivate extension Data {
|
||||
|
||||
/// This works (hopefully) in the same way as `String.padding(toLength: length, withPad: "\0", startingAt: 0)`.
|
||||
@inline(__always)
|
||||
private func zeroPad(_ length: Int) -> Data {
|
||||
var out = length < self.count ? self.prefix(upTo: length) : self
|
||||
out.append(Data(count: length - out.count))
|
||||
return out
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user