Как открыть и прочитать файл VSAM в z / OS с помощью IBM Kitura Swift - PullRequest
0 голосов
/ 10 мая 2019

Я пытаюсь открыть и прочитать файл VSAM для целей тестирования, используя Swift в USS (z / OS UNIX), но у меня возникают трудности при инициализации объекта 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.
...