mirror of
https://github.com/janet-lang/janet
synced 2024-09-30 16:00:40 +00:00
file/close returns an integer.
If opened with popen, returns the exit code. Otherwise returns nil.
This commit is contained in:
parent
fd2d706e33
commit
af23040d9c
@ -286,12 +286,15 @@ static Janet cfun_io_fclose(int32_t argc, Janet *argv) {
|
|||||||
#ifdef JANET_WINDOWS
|
#ifdef JANET_WINDOWS
|
||||||
#define pclose _pclose
|
#define pclose _pclose
|
||||||
#endif
|
#endif
|
||||||
if (pclose(iof->file)) janet_panic("could not close file");
|
int status = pclose(iof->file);
|
||||||
|
iof->flags |= IO_CLOSED;
|
||||||
|
if (status) janet_panic("could not close file");
|
||||||
|
return janet_wrap_integer(status);
|
||||||
} else {
|
} else {
|
||||||
if (fclose(iof->file)) janet_panic("could not close file");
|
if (fclose(iof->file)) janet_panic("could not close file");
|
||||||
}
|
|
||||||
iof->flags |= IO_CLOSED;
|
iof->flags |= IO_CLOSED;
|
||||||
return argv[0];
|
return janet_wrap_nil();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Seek a file */
|
/* Seek a file */
|
||||||
|
Loading…
Reference in New Issue
Block a user