From 81e1890c0f595c474cabcaa83f66882005336d93 Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Thu, 15 Jul 2021 14:15:08 +1000 Subject: 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 --- jim-file.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'jim-file.c') diff --git a/jim-file.c b/jim-file.c index 5532cb4..b73076f 100644 --- a/jim-file.c +++ b/jim-file.c @@ -140,11 +140,13 @@ static const char *JimGetFileType(int mode) /* *---------------------------------------------------------------------- * - * StoreStatData -- + * Jim_FileStoreStatData -- * * This is a utility procedure that breaks out the fields of a * "stat" structure and stores them in textual form into the - * elements of an associative array. + * elements of an associative array (dict). + * The result is also returned as the Tcl result. + * If varName is NULL, the result is only returned, not stored. * * Results: * Returns a standard Tcl return value. If an error occurs then @@ -161,7 +163,7 @@ static void AppendStatElement(Jim_Interp *interp, Jim_Obj *listObj, const char * Jim_ListAppendElement(interp, listObj, Jim_NewIntObj(interp, value)); } -static int StoreStatData(Jim_Interp *interp, Jim_Obj *varName, const jim_stat_t *sb) +int Jim_FileStoreStatData(Jim_Interp *interp, Jim_Obj *varName, const jim_stat_t *sb) { /* Just use a list to store the data */ Jim_Obj *listObj = Jim_NewListObj(interp, NULL, 0); @@ -849,7 +851,7 @@ static int file_cmd_lstat(Jim_Interp *interp, int argc, Jim_Obj *const *argv) if (file_lstat(interp, argv[0], &sb) != JIM_OK) { return JIM_ERR; } - return StoreStatData(interp, argc == 2 ? argv[1] : NULL, &sb); + return Jim_FileStoreStatData(interp, argc == 2 ? argv[1] : NULL, &sb); } #else #define file_cmd_lstat file_cmd_stat @@ -862,7 +864,7 @@ static int file_cmd_stat(Jim_Interp *interp, int argc, Jim_Obj *const *argv) if (file_stat(interp, argv[0], &sb) != JIM_OK) { return JIM_ERR; } - return StoreStatData(interp, argc == 2 ? argv[1] : NULL, &sb); + return Jim_FileStoreStatData(interp, argc == 2 ? argv[1] : NULL, &sb); } static const jim_subcmd_type file_command_table[] = { -- cgit v1.1