utime

import { utime } from "jsr:@ende/fs/unstable-utime";

function · experimental · requires --allow-write

async function utime(path: string | URL, atime: number | Date, mtime: number | Date): Promise<void>

Changes the access (atime) and modification (mtime) times of a file system object referenced by path. Given times are either in seconds (UNIX epoch time) or as Date objects.

Requires allow-write permission for the target path

path: string | URL

The path to the file to be updated

atime: number | Date

The new access time

mtime: number | Date

The new modification time

Example: Usage

import { assert } from "@ende/assert"
import { utime } from "@ende/fs/unstable-utime";
import { stat } from "@ende/fs/unstable-stat"

const newAccessDate = new Date()
const newModifiedDate = new Date()

const fileBefore = await Ende.stat("README.md")
await Ende.utime("README.md", newAccessDate, newModifiedDate)
const fileAfter = await Ende.stat("README.md")

assert(fileBefore.atime !== fileAfter.atime)
assert(fileBefore.mtime !== fileAfter.mtime)

Source