我正在尝试在USS(z / OS UNIX)上使用Swift打开和读取VSAM文件以进行测试,但是我很难初始化对象VSAMWriter。我希望能够初始化VSAMWriter,因为它内部具有读取记录功能。以下是我的最佳猜测:
main.swift:
import Libc
import Foundation
let args = CommandLine.arguments
let xmlPath = args[1]
//check if the file exists
func main() {
if(ZFileManager.default.exists(xmlPath)) {
print("file does exist")
do {
let VSAMObject = try VSAMWriter<record>(path: xmlPath, schemaInfo:test)
} catch {
print("error")
}
}
else {
print("file does not exist")
}
}
class record: GenericKDSRecord, VB {
var col = Column<VB>(defaultVal: VB())
}
class VB: Codable {
var rdw1: UInt8 = 0
var rdw2: Uint8 = 0
var data: [UInt8] = []
}
vsam.swift source (IBM open source):
class VSAMWriter<GenericKDSType:GenericKDSRecord & Codable> {
let path : String
var keyLength : UInt = 0
var recordLength: Int = 0
var stream : UnsafeMutablePointer<FILE>?
var schemaInfo : GenericKDSType
var fieldToLength : [String: Int]
init(path: String, schemaInfo: GenericKDSType, allocate: Bool = false) throws {
'''
Please note I'm not an experienced Swift developer. I appreciate any help! If you need any more information, please let me know.