Path.touch

void touch(bool existOk = true, Nullable!uint mode = Nullable!uint.init, Nullable!FileTimes times = Nullable!FileTimes.init) const

Create the file and/or update its timestamps, pathlib-like.

Behavior mirrors Python's Path.touch(exist_ok=True, mode=None, times=None):

  • If the file does not exist, creates an empty file.
  • If existOk is false and the file exists, throws an exception.
  • If times is provided, sets access and modification times accordingly; otherwise

uses the current time for both.

  • If mode is provided and the file is created, on POSIX the permission bits are

applied (masked by the current process umask); on Windows mode is ignored.

Note

Timestamp updates follow symlinks (affect the target).

Parameters

existOkIf false and the path exists, throw instead of updating times.
modeOptional POSIX permission bits to apply on creation (e.g., octal 0o644). Ignored on Windows.
timesOptional explicit timestamps to set; when omitted, both atime/mtime become now.
void touch() const

Convenience overload matching historical API: create or update with current time.