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
existOk | If false and the path exists, throw instead of updating times. |
mode | Optional POSIX permission bits to apply on creation (e.g., octal 0o644). Ignored on Windows. |
times | Optional explicit timestamps to set; when omitted, both atime/mtime become now. |