fixed 'system.open' bug
This commit is contained in:
parent
838871b4d9
commit
05f09fafcf
1 changed files with 7 additions and 7 deletions
|
|
@ -215,13 +215,13 @@ proc open(f: var File, filename: string,
|
||||||
mode: FileMode = fmRead,
|
mode: FileMode = fmRead,
|
||||||
bufSize: int = -1): bool =
|
bufSize: int = -1): bool =
|
||||||
var p: pointer = fopen(filename, FormatOpen[mode])
|
var p: pointer = fopen(filename, FormatOpen[mode])
|
||||||
result = (p != nil)
|
if p != nil:
|
||||||
f = cast[File](p)
|
result = true
|
||||||
if bufSize > 0 and bufSize <= high(cint).int:
|
f = cast[File](p)
|
||||||
if setvbuf(f, nil, IOFBF, bufSize.cint) != 0'i32:
|
if bufSize > 0 and bufSize <= high(cint).int:
|
||||||
sysFatal(OutOfMemError, "out of memory")
|
discard setvbuf(f, nil, IOFBF, bufSize.cint)
|
||||||
elif bufSize == 0:
|
elif bufSize == 0:
|
||||||
discard setvbuf(f, nil, IONBF, 0)
|
discard setvbuf(f, nil, IONBF, 0)
|
||||||
|
|
||||||
proc reopen(f: File, filename: string, mode: FileMode = fmRead): bool =
|
proc reopen(f: File, filename: string, mode: FileMode = fmRead): bool =
|
||||||
var p: pointer = freopen(filename, FormatOpen[mode], f)
|
var p: pointer = freopen(filename, FormatOpen[mode], f)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue