Initial implementation of APKINDEX, fetching, reading, parsing, & merging

This commit is contained in:
2024-11-08 21:22:33 +11:00
parent f6cbddb608
commit 941dfae317
18 changed files with 877 additions and 65 deletions

View File

@ -0,0 +1,30 @@
// SPDX-License-Identifier: Apache-2.0
import Foundation
public protocol Stream {
mutating func seek(_ whence: StreamWhence) throws(StreamError)
var tell: Int { get throws(StreamError) }
}
public enum StreamWhence {
case set(_ position: Int)
case current(_ offset: Int)
case end(_ offset: Int)
}
public enum StreamError: Error, LocalizedError {
case unsupported
case seekRange
case overflow
case fileHandleError(_ error: any Error)
public var errorDescription: String? {
switch self {
case .unsupported: "Unsupported operation"
case .seekRange: "Seek out of range"
case .overflow: "Stream position overflowed"
case .fileHandleError(let error): "Error from file handle: \(error.localizedDescription)"
}
}
}