mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 14:00:35 +00:00
* fix #19600 No error checking on fclose * add IOError to open
This commit is contained in:
@@ -324,7 +324,9 @@ const
|
||||
proc close*(f: File) {.tags: [], gcsafe.} =
|
||||
## Closes the file.
|
||||
if not f.isNil:
|
||||
discard c_fclose(f)
|
||||
let x = c_fclose(f)
|
||||
if x < 0:
|
||||
checkErr(f)
|
||||
|
||||
proc readChar*(f: File): char {.tags: [ReadIOEffect].} =
|
||||
## Reads a single character from the stream `f`. Should not be used in
|
||||
@@ -689,7 +691,7 @@ when defined(posix) and not defined(nimscript):
|
||||
|
||||
proc open*(f: var File, filename: string,
|
||||
mode: FileMode = fmRead,
|
||||
bufSize: int = -1): bool {.tags: [], raises: [], benign.} =
|
||||
bufSize: int = -1): bool {.tags: [], raises: [IOError], benign.} =
|
||||
## Opens a file named `filename` with given `mode`.
|
||||
##
|
||||
## Default mode is readonly. Returns true if the file could be opened.
|
||||
|
||||
Reference in New Issue
Block a user