getTimes

Get the access and modified times of file or folder name.

  1. void getTimes(R name, SysTime accessTime, SysTime modificationTime)
  2. void getTimes(R name, SysTime accessTime, SysTime modificationTime)
    void
    getTimes
    (
    R
    )

Parameters

name R

File/Folder name to get times for.

accessTime SysTime

Time the file/folder was last accessed.

modificationTime SysTime

Time the file/folder was last modified.

Throws

FileException on error.

Examples

import std.datetime : abs, SysTime;

scope(exit) deleteme.remove;
write(deleteme, "a");

SysTime accessTime, modificationTime;

getTimes(deleteme, accessTime, modificationTime);

import std.datetime : Clock, seconds;
auto currTime = Clock.currTime();
enum leeway = 5.seconds;

auto diffAccess = accessTime - currTime;
auto diffModification = modificationTime - currTime;
assert(abs(diffAccess) <= leeway);
assert(abs(diffModification) <= leeway);

Meta