When the file was last written, how many bytes it holds, and whether it exists: (modtime, size, file_exists).
file_modtime_and_size :: (
file_path: string
) -> (modtime: Apollo_Time, size: s64, file_exists: bool)
For a missing file or a path with a NUL byte it returns APOLLO_TIME_INVALID, 0 and false. A link is followed. The
time keeps the file system's resolution (nanoseconds on most Unix targets); compare two with compare_apollo_times.
A directory's size is whatever the system reports for it.
Parameters
- file_path: string
Returns
- modtime: Apollo_Time
- size: s64
- file_exists: bool
#import "Extensions/Environment";
#import "File";
base := environment_variable("TMPDIR");
if base == "" base = environment_variable("TEMP");
if base == "" base = "/tmp";
path := tprint("%/jai-doc-modtime.txt", base);
defer file_delete(path);
assert(write_entire_file(path, "copper"));
time, size, found := file_modtime_and_size(path);
assert(found && size == 6);
same, still_found := file_modtime(path);
assert(still_found && compare_apollo_times(time, same) == 0);
_, _, found = file_modtime_and_size(tprint("%-missing", path));
assert(!found);