Path.touch() method
pathlib-ts > Path > touch
Path.touch() method
Section titled “Path.touch() method”Create the file or update its timestamps with optional mode overrides.
Signature:
touch(options?: { mode?: number; existOk?: boolean; }): Promise<void>;Parameters
Section titled “Parameters”|
Parameter |
Type |
Description |
|---|---|---|
|
options |
{ mode?: number; existOk?: boolean; } |
(Optional) File creation behaviour flags ( |
Returns:
Promise<void>
Promise that settles once the touch operation completes.
Remarks
Section titled “Remarks”Implements CPython semantics where existOk controls whether existing files are tolerated.
Example
Section titled “Example”Priming cache files asynchronously
import { Path } from "pathlib-ts";
const cache = new Path("./.cache/state.json");await cache.touch({ existOk: true });