You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 26, 2020. It is now read-only.
import Foundation
import Libc
func readAs(path: String) {
print("Opening '\(path)' as file path.")
if let f = FileHandle(forReadingAtPath: path) {
process(file: f)
}
else {
print("Open failed; errno: \(errno)")
}
}
func readAs(url path: String) {
print("Opening '\(path)' as file URL.")
process(file: try! FileHandle(forReadingFrom: URL(fileURLWithPath: path)))
}
func process(file: FileHandle) {
print("Successful open")
let d = file.readDataToEndOfFile()
print("Read \(d)")
if let s = String(data: d, encoding: .utf8) {
print(s)
}
file.closeFile()
}
func main() {
let fileName = CommandLine.arguments[1]
readAs(path: fileName)
readAs(url: fileName)
}
main()
This program works fine when the file specified as arg 1 exists, but when it does not exist the attempt to open it using try! FileHandle(forReadingFrom: URL(fileURLWithPath: path)) actually returns a FileHandle instead of throwing an error. But a FatalError occurs on the attempt to read the file using that FileHandle.
DVFJS:/u/dvfjs/src:>./files dummy.txt
Opening 'dummy.txt' as file path.
Open failed; errno: 129
Opening 'dummy.txt' as file URL.
Successful open
Fatal error: Unable to read file: file Foundation/FileHandle.swift, line 42
CEE3201S The system detected an operation exception (System Completion Code=0C1).
From entry point $Ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtFTf4nxnnn_n at compile un
it offset +000000001060AE96 at entry offset +00000000000000FA at address 000000001060AE96.
[1] + Done(132) ./files dummy.txt
50463486 FSUM7739 Illegal instruction ./files
DVFJS:/u/dvfjs/src:>swiftc --version
5655-SFT V4.2 - IBM Toolkit for Swift on z/OS version 4.2.1-dev (LLVM 2ab0e7e2b7, Clang bf22bdb497, Swift df4dbc99f7)
Build Date: Nov 25 2018 11:18:42
Target: s390x-ibm-zos
The text was updated successfully, but these errors were encountered:
Take the following program:
This program works fine when the file specified as arg 1 exists, but when it does not exist the attempt to open it using
try! FileHandle(forReadingFrom: URL(fileURLWithPath: path))
actually returns a FileHandle instead of throwing an error. But a FatalError occurs on the attempt to read the file using that FileHandle.The text was updated successfully, but these errors were encountered: