std.file.time_last_modified - multiple declarations
- Function timeLastModified
- Function timeLastModified
Function timeLastModified
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 if FileExceptionsource 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.
Prototype
SysTime timeLastModified(R)( R name, SysTime returnIfMissing ) if (isInputRange!R && isSomeChar!(ElementEncodingType!R));
Parameters
| Name | Description |
|---|---|
| name | The name of the file to get the modification time for. |
| returnIfMissing | The time to return if the given file does not exist. |
Examples
if(timeLastModified(source) >= timeLastModified(target, SysTime.min))
{
// must (re)build
}
else
{
// target is up-to-date
}
Function timeLastModified
Returns the time that the given file was last modified.
Prototype
SysTime timeLastModified(R)( R name ) if (isInputRange!R && isSomeChar!(ElementEncodingType!R));
Throws
if the given file does not exist.
FileException
Authors
Walter Bright, Andrei Alexandrescu, Jonathan M Davis