如何使用IBM Kitura Swift在z / OS上打开和读取VSAM文件

时间:2019-05-10 18:13:56

标签: swift io zos kitura

我正在尝试在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.

0 个答案:

没有答案