diff options
author | Steve Bennett <steveb@workware.net.au> | 2021-07-15 14:15:08 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2022-04-14 11:18:01 +1000 |
commit | 81e1890c0f595c474cabcaa83f66882005336d93 (patch) | |
tree | 75e9fe03c05b9780c1a34039e508121bb6cfced6 /jim-aio.c | |
parent | 703ac20adb9daff423eea44f4af548f485a97254 (diff) | |
download | jimtcl-81e1890c0f595c474cabcaa83f66882005336d93.zip jimtcl-81e1890c0f595c474cabcaa83f66882005336d93.tar.gz jimtcl-81e1890c0f595c474cabcaa83f66882005336d93.tar.bz2 |
aio: TIP 603 - Implement stat of an open file handle
Although the interface is different ('$handle stat' vs 'chan configure -stat')
the behaviour is the same.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim-aio.c')
-rw-r--r-- | jim-aio.c | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -121,6 +121,7 @@ /* no fdopen() with ANSIC, so can't support these */ #undef HAVE_PIPE #undef HAVE_SOCKETPAIR +#undef Jim_FileStat #endif #if defined(HAVE_SOCKETS) && !defined(JIM_BOOTSTRAP) @@ -1426,6 +1427,20 @@ static int aio_cmd_onexception(Jim_Interp *interp, int argc, Jim_Obj *const *arg } #endif +#if defined(jim_ext_file) && defined(Jim_FileStat) +static int aio_cmd_stat(Jim_Interp *interp, int argc, Jim_Obj *const *argv) +{ + jim_stat_t sb; + AioFile *af = Jim_CmdPrivData(interp); + + if (Jim_FileStat(af->fd, &sb) == -1) { + JimAioSetError(interp, NULL); + return JIM_ERR; + } + return Jim_FileStoreStatData(interp, argc == 0 ? NULL : argv[0], &sb); +} +#endif + #if defined(JIM_SSL) && !defined(JIM_BOOTSTRAP) static int aio_cmd_ssl(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { @@ -1803,6 +1818,15 @@ static const jim_subcmd_type aio_command_table[] = { 1, /* Description: Sets buffering */ }, +#if defined(jim_ext_file) && defined(Jim_FileStat) + { "stat", + "?var?", + aio_cmd_stat, + 0, + 1, + /* Description: 'file stat' on the open file */ + }, +#endif #ifdef jim_ext_eventloop { "readable", "?readable-script?", |