Commits (3)
  • Rob Swindell's avatar
    Update the help text for the "file existence check" option · 13c520ef
    Rob Swindell authored
    This option actually controls whether the disk will be queried for the current file size and modification date/time (when listing) too.
    13c520ef
  • Rob Swindell's avatar
    Create some convenience functions for validating lib/dir/grp/sub nums · a466152f
    Rob Swindell authored
    There are lot of places in the code where subnums and dirnums (especially) are compared against total_subs and/or total_dirs or >= 0 without a ton of consistency. We should migrate to use these functions for validity-checking going forward.
    a466152f
  • Rob Swindell's avatar
    File's meta-object's "size" and "time" properties reflect current values · 623c49e4
    Rob Swindell authored
    Query the disk for file's current "size" and "time" values when get_list() or get() method is used with a "detail" level of >= DETAIL.NORMAL and the "check file existence" toggle option is enabled for this directory in SCFG.
    
    I pondered and contemplated whether this configuration setting should be checked/applied here or in the various JS scripts (e.g. filelist.js) and decided here was best to provide the most uniform/expected behavior, even though there is a performance impact. If a script doesn't need/use these properties, they should probably be specifying the DETAIL.MIN (minimal) detail level in their queries anyway, which will then bypass these performance-impacting disk queries.
    623c49e4
......@@ -251,11 +251,17 @@ set_file_properties(JSContext *cx, JSObject* obj, file_t* f, enum file_detail de
if(!JS_DefineProperty(cx, obj, "cost", val, NULL, NULL, flags))
return false;
}
val = UINT_TO_JSVAL(f->idx.size);
if(is_valid_dirnum(scfg, f->dir) && (scfg->dir[f->dir]->misc & DIR_FCHK) && detail >= file_detail_normal)
val = DOUBLE_TO_JSVAL((double)getfilesize(scfg, f));
else
val = UINT_TO_JSVAL(f->idx.size);
if(!JS_DefineProperty(cx, obj, "size", val, NULL, NULL, flags))
return false;
val = UINT_TO_JSVAL(f->hdr.when_written.time);
if(is_valid_dirnum(scfg, f->dir) && (scfg->dir[f->dir]->misc & DIR_FCHK) && detail >= file_detail_normal)
val = DOUBLE_TO_JSVAL((double)getfiletime(scfg, f));
else
val = UINT_TO_JSVAL(f->hdr.when_written.time);
if(!JS_DefineProperty(cx, obj, "time", val, NULL, NULL, flags))
return false;
if(f->hdr.when_imported.time > 0 || detail > file_detail_metadata) {
......
......@@ -1504,7 +1504,8 @@ void dir_cfg(uint libnum)
"`Check for File Existence When Listing:`\n"
"\n"
"If you want the actual existence of files to be verified while listing\n"
"directories, set this value to `Yes`.\n"
"directories and to have the current file size and modification time\n"
"reported when listing files, set this value to `Yes`.\n"
"\n"
"Directories with files located on CD-ROM or other slow media should have\n"
"this option set to `No`.\n"
......
......@@ -66,6 +66,11 @@ int getlibnum(scfg_t*, const char* code);
int getsubnum(scfg_t*, const char* code);
int getgrpnum(scfg_t*, const char* code);
BOOL is_valid_dirnum(scfg_t*, int);
BOOL is_valid_libnum(scfg_t*, int);
BOOL is_valid_subnum(scfg_t*, int);
BOOL is_valid_grpnum(scfg_t*, int);
faddr_t* nearest_sysfaddr(scfg_t*, faddr_t*);
#ifdef __cplusplus
......
......@@ -822,10 +822,30 @@ int getgrpnum(scfg_t* cfg, const char* code)
int i = getdirnum(cfg, code);
if(i >= 0)
return cfg->sub[i]->grp;
return cfg->sub[i]->grp;
return i;
}
BOOL is_valid_dirnum(scfg_t* cfg, int dirnum)
{
return (dirnum >= 0) && (cfg != NULL) && (dirnum < cfg->total_dirs);
}
BOOL is_valid_libnum(scfg_t* cfg, int libnum)
{
return (libnum >= 0) && (cfg != NULL) && (libnum < cfg->total_libs);
}
BOOL is_valid_subnum(scfg_t* cfg, int subnum)
{
return (subnum >= 0) && (cfg != NULL) && (subnum < cfg->total_subs);
}
BOOL is_valid_grpnum(scfg_t* cfg, int grpnum)
{
return (grpnum >= 0) && (cfg != NULL) && (grpnum < cfg->total_grps);
}
faddr_t* nearest_sysfaddr(scfg_t* cfg, faddr_t* addr)
{
uint i;
......