aboutsummaryrefslogtreecommitdiff
path: root/jim-file.c
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2021-07-15 14:15:08 +1000
committerSteve Bennett <steveb@workware.net.au>2022-04-14 11:18:01 +1000
commit81e1890c0f595c474cabcaa83f66882005336d93 (patch)
tree75e9fe03c05b9780c1a34039e508121bb6cfced6 /jim-file.c
parent703ac20adb9daff423eea44f4af548f485a97254 (diff)
downloadjimtcl-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-file.c')
-rw-r--r--jim-file.c12
1 files changed, 7 insertions, 5 deletions
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[] = {