File_Utilities module

add_modtime_and_size_if_missing

procedureSource

Fills in modification_time and size of info from info.full_name when the time is still APOLLO_TIME_INVALID. Returns whether the details are known: false, with had_error set, when they cannot be read. A record that already has a time is left alone and the answer is !had_error. visit_files fills these in itself on this target.

add_modtime_and_size_if_missing :: (info: *File_Visit_Info) -> bool

Parameters

Returns

bool
Example↗
#import "Extensions/Environment";
#import "File";
base := environment_variable("TMPDIR");
if base == "" base = environment_variable("TEMP");
if base == "" base = "/tmp";
path := tprint("%/jai-doc-add-modtime.txt", base);
defer file_delete(path);
assert(write_entire_file(path, "four"));
info := File_Visit_Info.{ full_name = path, modification_time = APOLLO_TIME_INVALID };
assert(add_modtime_and_size_if_missing(*info));
assert(info.size == 4);

See also