timeLastModified

fnSysTime timeLastModified(R)(R name) if (isSomeFiniteCharInputRange!R && !isConvertibleToString!R)

Returns the time that the given file was last modified.

Parameters

namethe name of the file to check

Returns

Throws

FileException if the given file does not exist.
fnSysTime timeLastModified(R)(auto ref R name) if (isConvertibleToString!R)

ditto

fnSysTime timeLastModified(R)(R name, SysTime returnIfMissing) if (isSomeFiniteCharInputRange!R)

Returns the time that the given file was last modified. If the file does not exist, returns returnIfMissing.

A frequent usage pattern occurs in build automation tools such as

make or ant. To check whether file target must be rebuilt from file source (i.e., target is

older than source or does not exist), use the comparison below. The code throws a FileException if source does not exist (as it should). On the other hand, the SysTime.min default makes a non-existing target seem infinitely old so the test correctly prompts building it.

Parameters

nameThe name of the file to get the modification time for.
returnIfMissingThe time to return if the given file does not exist.

Returns

A SysTime.

Example: -------------------- if (source.timeLastModified >= target.timeLastModified(SysTime.min)) { // must (re)build } else { // target is up-to-date } --------------------